top-down rpg style button interaction [SOLVED]

Started by thecatamites, Sat 23/01/2010 22:01:23

Previous topic - Next topic

thecatamites

Hello,
I'm making a short game in the style of top-down rpgs like Earthbound, etc., and I'm trying to set it up so that pressing the 'Z' key will interact with nearby people and objects. The way I'm doing this is by an on_key_press script that runs ProcessClick(player.x, player.y, eModeInteract) when Z is pressed and by having the NPCs be just part of the backround screen with a hotspot covering an area around them.

I think the problem I'm having has to do with the way the player x and y coordinates are calculated: my approach works okay for some characters at the top of the screen, when approaching them from the south, but for others near the bottom it doesn't work at all when the player is right next to/above them and then suddenly works when the character is a fair difference above them and should technically be outside the hotspot zone.

Basically I was wondering if anyone had any thoughts as to what the problem or solution here might be, or even alternate methods of pulling off the control scheme described above. Thanks!
Games 4 Schools Dot Com play games made for schools and teens to lkearn

tzachs

I think that's because the x & y of the player are in room co-ordinates, whereas GetAtScreenXY for hotspot is in screen co-ordinates.

Is your room a scrolling room?

If it is, try running instead of GetAtScreenXY(player.x,player.y) --> GetAtScreenXY(player.x + GetViewportX(), player.y + GetViewportY())

Khris

It's supposed to be
Code: ags
  ProcessClick(player.x - GetViewportX(), player.y - GetViewportY(), eModeInteract);

(To get from room to screen coords, substract the viewport coords.)

thecatamites

Games 4 Schools Dot Com play games made for schools and teens to lkearn

SMF spam blocked by CleanTalk