Camera Control in AGS...

Started by Ventus, Wed 19/11/2008 23:11:30

Previous topic - Next topic

Ventus

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...

Trent R

The AGS camera follows a character marked as the player character.

However, you can slightly get around it, check this thread for one way to do it.

~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Khris

You can choose the camera position (i.e. the room pixel appearing at the top-left of the screen) at will by using SetViewport().

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.

Creator

This is how I did it for a game I mad a few months back.

Code: ags

  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).

Julius Dangerous

___________________________________________________________

Ali

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.

Crimson Wizard

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.

Khris

Ramjuz dug this up from 2008... :)

Crimson Wizard

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. :)

SMF spam blocked by CleanTalk