Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Matti on Fri 17/04/2009 12:47:27

Title: SetViewPort problem (solved)
Post by: Matti on Fri 17/04/2009 12:47:27
Can I manually set the viewport / scroll the room while controlling the character? The room is supposed to scroll automatically every game cycle while the player should be able to freely move around, but the Setviewport function seems to block the character movement...

Thanks in advance.
Title: Re: SetViewPort problem
Post by: GarageGothic on Fri 17/04/2009 12:52:30
Yeah, it's definitely possible. That's exactly how the Smooth Scrolling Module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=33142.0) works, by calling SetViewport every frame in the repeatedly_execute_always. If you post your scrolling code, it would be easier to locate the problem.
Title: Re: SetViewPort problem
Post by: Matti on Fri 17/04/2009 13:04:48
Well, this is what I have in the rep-ex:


while (y>1) {
   SetViewport(0,y);
   y--;
   player.y--;
   Wait(1);
}


I just turned on the mouse cursor and realized that the wait(1) command seems to be the problem cause the cursor is always in wait mode. But when I delete the line, the background immediately moves to its end point (which is a bit strange imo since the background picture is 25000 px high).

Hm, what can I do about that?
Title: Re: SetViewPort problem
Post by: GarageGothic on Fri 17/04/2009 13:06:12
Yes, the Wait(1) is the problem. Is the "int y" definition stored outside or inside the rep_ex? If it's inside it will be reset to the default value every frame.

Edit: No, sorry, misread. Another problem is the "while" conditional. This makes the code wait until the y value is 0 until proceeding to the next frame. Remove the while and it should work. Instead do a check for "if (y>1)" to avoid y going below zero.

if (y>1) {
   SetViewport(0,y);
   y--;
   player.y--;
   }

Title: Re: SetViewPort problem (solved)
Post by: Matti on Fri 17/04/2009 13:19:22
Thanks, yeah. I just figured it out  ;).