So, I'm modding a game called Andy the Adventurer and making it into more of a spider man style thing. I want the player to be able to grab onto ledges. I've already made the code for making the player go up by four pixels, but what I need to do is get the coordinates of the nearest instance of a certain sprite. Closest to the player that is. It's the most efficient way to do it I think. I have a sprite specifically for ledge grabbing, and it's invisible. In the map editor, I place it directly next to any steep ledges. So yeah.
TLDR: How do I check the top-left corner location of the nearest instance of a sprite, to the player?
Still long, but better.
EDIT: I suppose a better question would be, how do I check if an x,y coordinate is inside a certain sprite on the map?
mget(x,y) is possibly what you are looking for?
i would personally recommend a table that is scanned from the map so you can do proper pythagoras to them however.
(at the start of a level just make an empty table, loop through every map tile, then add the positions to the table, use pythagoras to see if the player is close, and get the nearest)
[Please log in to post a comment]