I'm practicing on making a platformer. right now trying to make enemy that patrols back and forth over bunch of tiles. think of it like Mario's enemies how they go back and forth. for that i need to detect if the enemy is about to reach the end of the tiles so then it can reverse its direction. How do I achieve this? I tried to search the forum, but may be I didn't use right terms.
I tried using specific tile x and width, I was able to make it reverse direction on reaching the start, but reaching the end I couldn't because as far as i can see there is no way to detect how many tiles arranged in that area to calculate the end of that particular platform.
I tried using sin movement, but then this will be a problem since platforms are not equal in length. also I didn't find a way to detect in what direction that movement of the sin is going into so that I can mirror the sprite.
In sum: How to detect what tile/sprite/object exist in specific x y?