Sempiternam wrote:Hello people.
Here is the false error if found.
(Running Demonio4.PRG on Gemix)
GEMIX: Error en ejecución
ERROR_118: Hay demasiados textos activos en el programa.
LOCATION: WRITE_INT
PARAMETER: 1
VALUE: 0
Deleted code lines:
// write_int(0, 10, 10, 4, OFFSET x);
// write_int(0, 30, 10, 4, OFFSET y);
// write_int(0, 40, 20, 4, OFFSET Energia);
(Rerunning Demonio4.PRG: No errors)
Now Demonio4AI file is a perfect DIV2 'AI code' example for Gemix. The first post has the updated files (21 November 2009).
- Next Step: Game Balance -
Ohh, then this was the mistake...
actually this si an error of DIV2, because the texts with the same coordinates and properties were recreated, but worked well in DIV 1, some examples:
code executed on
DIV 1- Code: Select all
program test;
begin
repeat
write(0, 160, 100, 4, "DIV"); // after 512 texts created DIV throw the runtime error 118, OK correct
frame;
until(key(_esc));
end
code executed on
DIV 2- Code: Select all
program test;
begin
repeat
write(0, 160, 100, 4, "DIV"); // the text is recreated on each time, ERROR! this is wrong beaviour
frame;
until(key(_esc));
end
As you can see the operation is different between DIV1 and DIV2, because DIV2 has a bug, the correct behaviour is like DIV1.
but in other languages this may be correct, so we decided to double implementation:
1 - the default behaviour is like
DIV1: each call of WRITE's functions create a new text object
2 - using the new function
SET_WRITE_BEHAVIOUR you can change the behavior as DIV2
So, this is how you can use on Gemix...
Default behaviour:
- Code: Select all
program test;
begin
repeat
write(0, 160, 100, 4, "Gemix"); // after 65536 texts created Gemix throw the runtime error 118, OK correct
frame;
until(key(_esc));
end
Behaviour like
DIV2- Code: Select all
program test;
begin
set_write_behaviour(wri_overwrite); // set the behaviour overwrite for texts with the same properties.
repeat
write(0, 160, 100, 4, "Gemix"); // the text is recreated on each time (is not the best use, but OK)
frame;
until(key(_esc));
end
As a final consideration, the most performant to use the texts is to create them out of the loops:
- Code: Select all
program test;
begin
write_int(0, 160, 100, 4, &x); // the text is created one time (the best performance)
repeat
x++; // the engine automatically update the text that use this variable with the new value
frame;
until(key(_esc));
end
I hope you serve as an help for the creation of your games
