Mappy Collision Help

BlitzMax Forums/BlitzMax Beginners Area/Mappy Collision Help

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I don't know about Mappy specifically, but I was doing player-tile collision detection in a similar way and it was very glitchy.. but then i changed to something like this:

While ImagesCollide(playerbottom,player_x,player_y,player_frame,tilesprite,tile_x,tile_y,tile_frame)
     player_y:-1
Wend

While ImagesCollide(playertop,player_x,player_y,player_frame,tilesprite,tile_x,tile_y,tile_frame)
     player_y:+1
Wend

While ImagesCollide(playerleft,player_x,player_y,player_frame,tilesprite,tile_x,tile_y,tile_frame)
     player_x:+1
Wend

While ImagesCollide(playerright,player_x,player_y,player_frame,tilesprite,tile_x,tile_y,tile_frame)
     player_x:-1
Wend


..where playertop, playerbottom, playerleft and playerright are sprites - the same size as the player sprite - with just the top, bottom, left and right bit of the player sprite on each... if that makes sense.

splitting the player's collision mask into 4 parts and changing from "if" to "while" solved all the glitches and it now works perfectly, for any shape/size of tile, and for moving tiles/enemies etc...

so you could use the same method with the mappy collision commands instead of ImagesCollide() I guess.

if you do it this way you have to be careful and make sure the player will definately move off the tile though, or it'll get stuck in an infinite "while" loop :)

there might be better ways of doing it, i dunno.