Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: the Mask dot Bitmap on Thu 07/01/2021 18:11:09

Title: Positioning character further down screen [SOLVED]
Post by: the Mask dot Bitmap on Thu 07/01/2021 18:11:09
This one room, the room graphic is larger than 320x200, the entire room is walkable

and I want the character to display at the bottom of the screen ( say at like y 185) while he scrolls around the room.

default is that he's somewhere in the middle.

here's an illustration of my problem:
(https://i.imgur.com/ZMD6pdS.png)

Best I could come up with was that i need to repeatedly tell the program to push the viewport up the y axis, but I can't seem to wrap my head around how viewports work
even after reading this https://adventuregamestudio.github.io/ags-manual/UpgradeTo35.html

Thanks in advance for any help.
Title: Re: Positioning character further down screen
Post by: Khris on Thu 07/01/2021 18:13:52
Edit: got it.

You need to set the camera coordinates in the room's repeatedly_execute event (or late_repeatedly_execute_always).
Something like
Code (ags) Select
  Game.Camera.SetAt(player.x - 160, player.y - 185);

edit: code fixed
Title: Re: Positioning character further down screen
Post by: the Mask dot Bitmap on Thu 07/01/2021 18:37:07
Quote from: Khris on Thu 07/01/2021 18:13:52
Edit: got it.

You need to set the camera coordinates in the room's repeatedly_execute event (or late_repeatedly_execute_always).
Something like
Code (ags) Select
  Camera.SetAt(player.x - 160, player.y - 185);

Thanks for helping.
I get this error when trying to run:
room25.asc(37): Error (line 37): must have an instance of the struct to access a non-static member

I've read about structs... I don't quite get it.
Title: Re: Positioning character further down screen
Post by: Crimson Wizard on Thu 07/01/2021 18:51:56
It should be Game.Camera.SetAt. Game.Camera is an instance of camera contained in Game struct. Just "Camera" is a type of object.
Title: Re: Positioning character further down screen
Post by: the Mask dot Bitmap on Thu 07/01/2021 18:58:38
Quote from: Crimson Wizard on Thu 07/01/2021 18:51:56
It should be Game.Camera.SetAt. Game.Camera is an instance of camera contained in Game struct. Just "Camera" is a type of object.

Thanks, that worked!

the character was vibrating a lot, so I moved it into late_repeatedly_execute_always.