Sprite Collision With Map Tiles - Printable Version +- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum) +-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7) +--- Thread: Sprite Collision With Map Tiles (/showthread.php?tid=114) |
Sprite Collision With Map Tiles - Daniel H. - 06-19-2018 Hi, I'm trying to get collision to work between a sprite and a map tile. From reading the docs, it would seem that there is no built in Tilengine functionality to check for this kind of collision. Am I correct in saying this? I turned to whatever examples I could find. The best I could find was from the Super Mario Clone in Player.cs. Code: if (y < oldy) Am I on the right track and are there any other examples of how this can be done? RE: Sprite Collision With Map Tiles - megamarc - 06-22-2018 Hi Daniel! You're on the right way. There's no built-in mechanism to do sprite vs playfield collision detection, but there are some helper functions to aid you. The usual way is to define some "hot points" in your sprite, usually spaced by the same amount of pixels than the tileset you're checking collision. Then test the suitable points, depending on the motion direction, in which tiles they fall and check their types. This is what SuperMarioClone and PythonPlatformer sister projects do. |