does someone have a demo or could point me some documentation about how can I make a sprite walk on a irregular path? I’m used to work with tiles and that is fairly easy to check collision. I don’t have any idea how I can code it.
define irregular path =D
I don’t know the term to use… but I want to do something like miners4k: http://www.java4k.com/index.php?action=games&method=play&gid=55
I do this like
you know the direction the sprite is moving and gravity
then I do “virtually move”, then “check if sprites is colliding with wall” with pixels in this case as it is much more precise, and move if not
isn’t too expensive to test collision detection at pixel level? I’m used to use 2D tiles and it’s really faster. I was wondering if there’s a technique for this “irregular path”
There are multiple ways of doing this. You usually would divide the game area in multiple tiles (either in screen space or like in a traditional tiles-engine), then you evaluate the tiles in your moving direction that would be in range of your character with its current speed (mostly this would be the one the character is in and the one directly beside in moving direction). Then you check for collisions either per-pixel or per collision geometry. A collision geometry is a polygon representating the edge of your obstacles. The latter is obviously faster, but for games like miners4k you can’t precalculate a collision geometry.
I was looking at the source code of miners4k and found the following comment in the code:
Create the heightmap for the surface by subdivision
Does it have something to do with my question? I noticed that it used everywhere to check the collision