Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jojowl80 on Tue 08/09/2020 23:51:15

Title: Panning a room
Post by: Jojowl80 on Tue 08/09/2020 23:51:15
I am trying to make my invisible player walk across a room to  to make it look like a cutscene. The room is 400 in length, so I want it topan to the other half of the room.

Code (ags) Select


function room_Load()
{
aFog.Stop();
sAirplane.Play();
player.Transparency = 100;
  gMain.Visible = false;

}


function room_AfterFadeIn()
{
Wait(200);
aOrcus.Play();
player.Move(35, 188, eBlock);
}



He starts on the right side of the room, but he doesn't move an inch from the spot he enters on.
Title: Re: Panning a room
Post by: Jack on Wed 09/09/2020 01:03:43
room_RepExec() is called every non-blocked frame, so in there you would move the viewport along in small increments with SetViewport.

Something like:

Code (ags) Select

  int horizontalPosition = GetViewportX();
  if (horizontalPosition > 0)
  {
    SetViewport(horizontalPosition - 1, 0);
  }


This will decrease the vertical position by one pixel each frame. You can add more stuff to delay the starting of the scroll, like a bool to signal when it should scroll and not.

To move right, you would increase the horizontal position, and the if would look like:

Code (ags) Select

if (horizontalPosition < Room.Width - System.ScreenWidth)


You should make the player move a non-blocking action so the rest of the script functions can run while it is moving, or handle the scrolling in the room's repeatedly_execute_always.
Title: Re: Panning a room
Post by: Khris on Wed 09/09/2020 07:31:24
Have you drawn a walkable area? You can also use  eAnywhere  in the  .Move  command instead.
Title: Re: Panning a room
Post by: Cassiebsg on Wed 09/09/2020 17:05:19
Also, this might be related to the fact that AGS does not move invisible objects/characters. You can try and set his transparency to 99 instead of 100 and see if it makes a difference.
But to pan the room, you don't really need a character to move, just use Jack's code.  ;) Though, if you are using the newer version of AGS (3.5) the command has been updated, and you should use the Camera command instead.
Title: Re: Panning a room
Post by: Crimson Wizard on Wed 09/09/2020 17:36:07
Quote from: Cassiebsg on Wed 09/09/2020 17:05:19
Also, this might be related to the fact that AGS does not move invisible objects/characters. You can try and set his transparency to 99 instead of 100 and see if it makes a difference.

Not that's wrong, it moves transparent object, it does not move objects which have ".Visible = false" or ".on = false".
Title: Re: Panning a room
Post by: Cassiebsg on Wed 09/09/2020 18:11:37
Okay, I wasn't sure if 100 was equal to false on either one of those, that's why I suggested to try it, since I am sure that 99 isn't.  ;)