[Solved] Face Location in Scrolling Room.

Started by glurex, Thu 20/10/2022 01:57:02

Previous topic - Next topic

glurex

Hi :)

I realize I have a problem with "face location" in scrolling rooms (in "normal" rooms it works great). I set FaceLocation to get coordinates from mouse, so when the cursor interacts with something like a character, hotspot, object... in some specific side of the room the player character turns that direction.
I suspect that this problem in scrolling rooms have to do with room coordinates being different to screen coordinates. So instead of the classic

Code: ags
player.FaceLocation(mouse.x, mouse.y);

I write this:

Code: ags
player.FaceLocation(mouse.x - (Game.Camera.X), mouse.y - (Game.Camera.Y));

But didn't work at all, and now I'm pretty confuse about it  :-\





Crimson Wizard

It should be
Code: ags
player.FaceLocation(mouse.x + (Game.Camera.X), mouse.y + (Game.Camera.Y));

glurex

Quote from: Crimson Wizard on Thu 20/10/2022 02:06:16It should be
Code: ags
player.FaceLocation(mouse.x + (Game.Camera.X), mouse.y + (Game.Camera.Y));

Many thanks CW!  :-D

Khris

Screen coordinates are limited to the screen size while a scrolling room's coordinates can be much larger. Therefore you need to add the camera coords to go from screen coordinates to room coordinates, subtract them to go from room to screen.

And no need to put Game.Camera.X in parens btw.

glurex

Quote from: Khris on Thu 20/10/2022 08:00:25subtract them to go from room to screen.

Thanks! Now I understand what I was doing wrong.

Quote from: Khris on Thu 20/10/2022 08:00:25And no need to put Game.Camera.X in parens btw.

That's right, good observation. It was a remainder of a primitive idea (I wanted to add some pixels of "distance", but later I discarded that idea.) and I forgot to remove them.

SMF spam blocked by CleanTalk