Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Danvzare on Thu 13/12/2018 18:23:23

Title: How do I find the player's coordinates relative to the screen?
Post by: Danvzare on Thu 13/12/2018 18:23:23

I think my subject line says it all, but I'll try to explain further.


I want to use:
Code (ags) Select
Room.ProcessClick(player.x, player.y, eModeInteract);
But I can't, because player.x and player.y returns the position of the player relative to the room, and Room.ProcessClick wants an x and y value relative to the screen. This in turns causes a lot of problems for scrolling rooms.
I'm sure the answer is a simple formula of some kind involving the viewport and room width or something, but I can't for the life of me figure it out.
Title: Re: How do I find the player's coordinates relative to the screen?
Post by: Slasher on Thu 13/12/2018 19:01:57

Scrolling rooms use;
Code (ags) Select

Room.ProcessClick(player.x + GetViewportX(), player.y+ GetViewportY());


Title: Re: How do I find the player's coordinates relative to the screen?
Post by: Danvzare on Thu 13/12/2018 19:14:49

Changing it to:
Code (ags) Select

Room.ProcessClick(player.x - GetViewportX(), player.y - GetViewportY());


Makes it work perfectly. Thank you so very much Slasher.  :D
And sorry for being so very VERY dumb.