Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dave Gilbert on Thu 09/11/2006 19:03:51

Title: Issue with rawdrawline (SOLVED)
Post by: Dave Gilbert on Thu 09/11/2006 19:03:51
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
Title: Re: issue with rawdrawline
Post by: Khris on Thu 09/11/2006 19:07:11
Try:

RawSaveScreen();  // gets called once only

rep_ex() {
Ã,  RawDrawLine(...);
Ã,  Wait(1);
Ã,  RawRestoreScreen():
}
Title: Re: issue with rawdrawline
Post by: Dave Gilbert on Thu 09/11/2006 19:30:10
Hm.  I still get the flicker, but it's less severe.  Is there any way to optimise this?
Title: Re: issue with rawdrawline
Post by: Kweepa on Thu 09/11/2006 19:55:40

RawSaveScreen(); // called once only from player enters screen (before fade in)

rep_ex() {
  RawRestoreScreen();
  RawDrawLine(...);
}
Title: Re: issue with rawdrawline
Post by: Dave Gilbert on Thu 09/11/2006 19:57:47
And BAM!  That did it.  Thanks, Steve!
Title: Re: issue with rawdrawline
Post by: Khris on Thu 09/11/2006 20:46:22
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?
Title: Re: issue with rawdrawline
Post by: Kweepa on Thu 09/11/2006 21:07:01
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.
Title: Re: issue with rawdrawline
Post by: Gregjazz on Thu 09/11/2006 23:36:21
This is true, because without the "Wait(1);" the script will be executing at the actual game speed.
Title: Re: issue with rawdrawline
Post by: Khris on Fri 10/11/2006 04:40:12
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
Title: Re: issue with rawdrawline
Post by: SSH on Fri 10/11/2006 06:48:14
If you set Game.Vsync to 1 then you do need a wait (or to fall out of rep_ex)