Jibble

Author Topic: How do I find the player's coordinates relative to the screen?  (Read 123 times)

Danvzare

  • The Man with No Name
    • I can help with AGS tutoring
    • I can help with proof reading
    • I can help with scripting
    • I can help with voice acting

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


I want to use:
Code: Adventure Game Studio
  1. 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.

Slasher

  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on a game that was nominated for an AGS Award!

Scrolling rooms use;
Code: Adventure Game Studio
  1. Room.ProcessClick(player.x + GetViewportX(), player.y+ GetViewportY());
  2.  
  3.  
  4.  

Danvzare

  • The Man with No Name
    • I can help with AGS tutoring
    • I can help with proof reading
    • I can help with scripting
    • I can help with voice acting

Changing it to:
Code: Adventure Game Studio
  1. 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.