Hi all,
I'm having a little issue that probably has a simple stupid solution.
I have a line, made with rawdrawline, that I want to move around the room. Basically the line starts from a specific point and is always pointing at a character. The character walks around the room and the line moves with it. (This is, in essence, to simulate a dog on a leash).
I did it like this:
RawSaveScreen();
RawDrawLine(220, 193,cDog.x, cDog.y);
RawRestoreScreen();
and put it in the repeatedly_executable section of my room script. It seems to have worked, but it happens so fast that you can't see the line.
I put a Wait(1); between the second and third lines, but that didn't work well because the line flickered and it slowed down the game.
Any suggestions appreciated!
Cheers,
-Dave
Try:
RawSaveScreen(); // gets called once only
rep_ex() {
Ã, RawDrawLine(...);
Ã, Wait(1);
Ã, RawRestoreScreen():
}
Hm. I still get the flicker, but it's less severe. Is there any way to optimise this?
RawSaveScreen(); // called once only from player enters screen (before fade in)
rep_ex() {
RawRestoreScreen();
RawDrawLine(...);
}
And BAM! That did it. Thanks, Steve!
Ah, my mistake then.
In a project of mine (a 3D-Chrono Trigger-like battle engine), I'm using
rep_ex() {
RawClearScreen(0);
draw_All(); // many array operations, triangular stuff and char movement in here
Wait(1);
}
This does it for me and is fast without flickering even on my old AMD 700Mhz / 196 MB machine.
Does the order matter if there are only two commands in rep_ex()? Or is it because I'm using RawClearScreen(0)?
Or is it something entirely different?
The draw order is significant - you should clear the screen, or restore the rawdrawn screen, before drawing anything on top.
You shouldn't need to Wait(1) in any case. This will happen automatically between frames, and adding a Wait(1) will I believe slow down the game to half speed.
So, for example, in the code you gave Dave, the sequence would be
draw line
wait
copy frame buffer to screen
restore screen
copy frame buffer to screen
One frame with the line, one without.
For your engine, it will be much faster to remove the Wait(1); although the game speed will double.
This is true, because without the "Wait(1);" the script will be executing at the actual game speed.
Damn. Somehow I expected graphical changes not to be visible until a call to Wait().
I used to program in AMOSPro where a WaitVbl = Wait(1) was necessary.
Thanks! :D
If you set Game.Vsync to 1 then you do need a wait (or to fall out of rep_ex)