Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Ventus on Wed 19/11/2008 23:11:30

Title: Camera Control in AGS...
Post by: Ventus on Wed 19/11/2008 23:11:30
i'm new here and im currently practicing creating a game using AGS... i have a question...

Is camera control possible in AGS? if so, can anyone please teach me how to do it? tnx...
Title: Re: Camera Control in AGS...
Post by: Trent R on Thu 20/11/2008 00:23:20
The AGS camera follows a character marked as the player character.

However, you can slightly get around it, check this thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36051.0) for one way to do it.

~Trent
Title: Re: Camera Control in AGS...
Post by: Khris on Thu 20/11/2008 01:38:20
You can choose the camera position (i.e. the room pixel appearing at the top-left of the screen) at will by using SetViewport() (http://www.adventuregamestudio.co.uk/manual/SetViewport.htm).

The arguably best way is to come up with your own conditions/formula and run them inside the global script's repeatedly_execute function.

Just keep in mind that calling it every game loop i.e. 40 times a second might cause the scrolling to be a bit jerky.
Title: Re: Camera Control in AGS...
Post by: Creator on Thu 20/11/2008 03:13:11
This is how I did it for a game I mad a few months back.


  if (IsKeyPressed(372) == 1) { // Up
    SetViewport(GetViewportX(), GetViewportY()-1);
  }
  if (IsKeyPressed(377) == 1) { // Right
    SetViewport(GetViewportX()+1, GetViewportY());
  }
 
if (IsKeyPressed(375) == 1) { // Left
   SetViewport(GetViewportX()-1, GetViewportY());
}
if (IsKeyPressed(380) == 1) { // Down
   SetViewport(GetViewportX(), GetViewportY()+1);
}
  if (player.Moving == true) {
    ReleaseViewport(); // When the player starts moving again the camera snaps back to his position
}


And I put that in the script of the rooms that were larger than the screen resolution (though you can have it in the Global Script if it's for all your rooms).
Title: Re: Camera Control in AGS...
Post by: Julius Dangerous on Wed 13/08/2014 21:19:14
Thanks! very useful
Title: Re: Camera Control in AGS...
Post by: Ali on Thu 14/08/2014 13:27:29
You can also create simple camera moves using this module:

http://www.adventuregamestudio.co.uk/forums/index.php?topic=33142.0

For camera moves set the targetCharacter to an invisible cDummy character, then use that character to control where the camera should be aiming.
Title: Re: Camera Control in AGS...
Post by: Crimson Wizard on Thu 14/08/2014 14:29:07
Quote from: Creator on Thu 20/11/2008 03:13:11
This is how I did it for a game I mad a few months back.

<...>

And I put that in the script of the rooms that were larger than the screen resolution (though you can have it in the Global Script if it's for all your rooms).

You can put the key-handling function in GlobalScript, but call it from rooms - this will reduce code duplication greatly.
Title: Re: Camera Control in AGS...
Post by: Khris on Fri 15/08/2014 01:18:20
Ramjuz dug this up from 2008... :)
Title: Re: Camera Control in AGS...
Post by: Crimson Wizard on Fri 15/08/2014 08:37:30
Quote from: Khris on Fri 15/08/2014 01:18:20
Ramjuz dug this up from 2008... :)
Ouch... did not notice I am giving comment to 2008th post. :)