Getting the cordinates for where the Game.Camera is atm (Debug purpose)

Started by AndreasBlack, Fri 27/05/2022 14:20:55

Previous topic - Next topic

AndreasBlack

I wish when i press Ctrl + D, that i'd show what the camera is set to valuewise x,y?

I have a large room (Think 10 floors hotel) and i've sat here and guessed my way thru values and it's not working out so good. I need some more solid method of doing this. The Character should walk up and down stairs to reach floor 1, 2 etc etc. And it would be easier to find the right values if that could be displayed with a "Display ("Camera is at x,y"); I'm guessing shouldn't be so hard to do?

I hope you'll understand what i'm after! Maybe this could be added into the Ctrl+ D for AGS 3.6, i don't know. I've had good use of that feature for where the Character is, but it would be nice to know where the camera is as well

Thanks!

Crimson Wizard

You can read Game.Camera.X and Y properties, and you may handle Ctrl+D in on_key_press, or even print that on a label in e.g. repeatedly_execute_always.

Or, if you want to find out the room coordinates under the middle of the screen, then it will be Camera.X + Camera.Width / 2 and Camera.Y + Camera.Height / 2 respectively.

Camera article in the manual: https://adventuregamestudio.github.io/ags-manual/Camera.html

Vincent

Quote from: AndreasBlack on Fri 27/05/2022 14:20:55
And it would be easier to find the right values if that could be displayed with a "Display ("Camera is at x,y"); I'm guessing shouldn't be so hard to do?

To insert the value of variables into a message it's use to do like this:
Code: ags

Display(String.Format("CameraX: %d, CameraY: %d", Game.Camera.X, Game.Camera.Y));

AndreasBlack

Turns out Camera is not what i'm looking for really. It's probably the Viewport that i need! Sorry for the confusion.

Since i've managed to guess my way to the right setting when going down stairs. I pushed my set up debug button and the values the Camera is showing, clearly shows different values. Which leads me to believe it's the Viewport that is the real numbers i'm after. 10 Floors and having to guess is not a viable option. (laugh)

The manual helps me nothing looking at Viewport just stats the obvious. It's readable, but not how to apply it.

Edit:Thanks Vincent, i was looking for that feature too!  (nod)

Code: ags
 
Display ("The Width is set to %d", Viewport.X + ??? Viewport.Width / 2);  

Crimson Wizard

Well, I have to say that currently I don't understand the problem at all.
Camera is in room coordinates, it tells which part of the room is currently visible. Viewport is in screen coordinates and tells where on screen the room is displayed. Character walks in room coordinates (like camera).

Why do you have to guess where your floors are located using camera or viewport anyway? Are not you are the one who draws the room? You should know their coordinates...

Perhaps if you could post a screenshot and mark the location your are trying to find out?

Vincent

Sorry but as Crimson says too I don't understand much, maybe even if you make a video it would give the idea. Anyway just to say that Camera.X, Camera.Y, Camera.Width, Camera.Height, Viewport.X, Viewport.Y, Viewport.Width and Viewport.Height are not only readable as far as the manual says if I haven't read it wrong (In AGS 3.5.0.29-P7).

AndreasBlack

I think i've finally solved it. Jesus, it's the rellax module that is giving me the headaches. Even tho it looks nice when it works! (laugh)
Turning of smooth cam then it finally locked the screen where it should be instantly, instead of doing some weird jump around and then eventually landing "right".
No worries guys, i'm tired and it's so much things that could go wrong and have gone wrong. Walkbehinds/walkeable areas that needs to be turned on/off depending on if you are on a certain floor, etc. I'm probably way overcomplicating stuff atm (wrong)

SMF spam blocked by CleanTalk