Scrollable room camera

Started by Slasher, Tue 20/09/2022 14:12:54

Previous topic - Next topic

Slasher

Hi,

I've always been used to GetViewport but it seems Camera is the new way.

Ok. You get into a lift. Press floor button (gui) Lift and Char rises/lowers to the floor chosen. The lift arrives at the floor with character inside but the room top is not visible because the character is low in the room.... i need to the screen to show whole room with the char at the bottom in lift.  Room scrollable is 300wide  x 820high....

Hope you understand my issue.

Thank you..



Crimson Wizard

#1
Quote from: Slasher on Tue 20/09/2022 14:12:54i need to the screen to show whole room with the char at the bottom in lift.  Room scrollable is 300wide  x 820high....

Do you mean that you need to move the camera up, or zoom camera out to show more of the room at once?

Regarding old functions (GetViewport and so on), if you search for them in the manual, their description has a note that tells which functions to use instead.
Also, there's a table of outdated functions, which tells the replacements:
https://adventuregamestudio.github.io/ags-manual/ObsoleteScriptAPI.html

Snarky

You use

Camera.SetAt(int x, int y);

the same way you'd previously use

SetViewport(int x, int y);

In this case you'd probably want to scroll it up so Camera y=0.

Slasher

Cheers guys but...

GlobalScript.asc(1094): Error (line 1094): must have an instance of the struct to access a non-static member

Khris

Afaik you need

Code: ags
  Game.Camera.SetAt(...);

Crimson Wizard

We need better code examples in the manual... because currently it has none.
Also I just realized that Camera's article does not mention the Game.Camera object, so there's no obvious connection.

Slasher


Nahuel

I thin you can also follow up the lift movement also and follow with x y the camera I use it for panning the room while on cutscenes.
Code: ags
int i=0;
while ( i<=53 ){
  i++;
  Game.Camera.SetAt(Game.Camera.X - 6, Game.Camera.Y);
  Wait(4);
}
Life isn't a game. Let's develop a life-like-game.

Crimson Wizard

#8
Strictly speaking, the above code may be simplified, as you already have X coordinate that you may use in a condition:
Code: ags
while ( Game.Camera.X > X_DESTINATION ){
  Game.Camera.SetAt(Game.Camera.X - 6, Game.Camera.Y);
  Wait(4);
}

Or simplified even more:
Code: ags
while ( Game.Camera.X > X_DESTINATION ){
  Game.Camera.X -= 6;
  Wait(4);
}

Naturally, vertical movement will require changing Y instead; and moving in opposite direction will require adding instead of subtracting and testing for (Camera.X < X_DESTINATION).

Crimson Wizard

#9
I expanded the Camera and Viewport articles with practical examples and minor additions; they are not published in the official manual yet, but may be read in the wiki source:
https://github.com/adventuregamestudio/ags-manual/wiki/Camera
https://github.com/adventuregamestudio/ags-manual/wiki/Viewport

AndreasBlack

If you aren't already. Use the tweenmodule, it works great for elevators and all kinds of camera movements. (nod)

SMF spam blocked by CleanTalk