Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TMuh on Sat 13/07/2013 12:01:31

Title: Drawingsurface (How to refresh/update background?)
Post by: TMuh on Sat 13/07/2013 12:01:31
Im doing level editor for my tilebased game. Level is drawn to the background and then exported as a bmp file. The problem is that one command in the editor is supposed to fill entire background with the selected tile graphic. Drawing works fine but the background doesnt update. I can update background by using wait command between code but id like to know if there is more proper way to do it. And id like to understand how drawingsurface works and why it doesnt update background rightaway.

Without wait command background updates only if I for example move character on the screen and the area where character moves is updated.

if (keycode == eKeyCtrlF) {
ViewFrame *frame = Game.GetViewFrame(CURSORVIEW,  0, 0);
DrawingSurface *mainBackground = Room.GetDrawingSurfaceForBackground(0);
int tx = 0; int ty = 0;
while (ty < 480) {
  while (tx < 640) {   
    mainBackground.DrawImage(tx, ty, frame.Graphic);
    //Wait(1); IT WORKS IF I USE WAIT COMMAND HERE BUT IT SLOWS THE EDITOR
    tx = tx + 32;
  }
  tx = 0;
  ty = ty + 32;
}
mainBackground.Release();
}
Title: Re: Drawingsurface (How to refresh/update background?)
Post by: Khris on Sat 13/07/2013 12:13:10
Whenever you're drawing something to a drawing surface, you're not changing the screen, you're just changing the part of the RAM that stores the DrawingSurface. Only when the next game loop arrives, and the engine redraws the screen, changes become visible. Calling Wait(1); will run one game loop and update the screen.

There are a couple of solutions here: move the Wait() command to the outer loop, or increase the Game's Speed: SetGameSpeed(120); (default is 40). Or do both.
Title: Re: Drawingsurface (How to refresh/update background?)
Post by: TMuh on Sat 13/07/2013 12:16:45
Thanks for quick reply. Moving wait to outer loop did the job.