Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: selmiak on Fri 17/06/2011 20:15:55

Title: how to get absolute mouse coordinates
Post by: selmiak on Fri 17/06/2011 20:15:55
I want the exact room coordinates where a mouseclick happens and mouse.x for example only gives me the screen coordinates and not the room coordinates. What do I use? GetAtRoomXY doesn't help as it just tell what is there but doesn't give the coordinates.
Title: Re: how to get absolute mouse coordinates
Post by: barefoot on Fri 17/06/2011 20:19:49
I think checkout

GetViewportX() and GetViewportY()


barefoot
Title: Re: how to get absolute mouse coordinates
Post by: selmiak on Fri 17/06/2011 20:33:38
with (GetViewportX()+mouse.x) it works, thanks barefoot :)

strange that there is no native expression for this...
Title: Re: how to get absolute mouse coordinates
Post by: monkey0506 on Fri 17/06/2011 21:20:12
Well you could write some custom functions pretty easily:

int RoomXToScreenX(int x)
{
  return (x - GetViewportX());
}

int RoomYToScreenY(int y)
{
  return (y - GetViewportY());
}

int ScreenXToRoomX(int x)
{
  return (x + GetViewportX());
}

int ScreenYToRoomY(int y)
{
  return (y + GetViewportY());
}