I had a few questions concerning Mappy collision. I'm working on a side-scrolling platformer, and have just switched over to using Mappy. I've adapted the collision code from the example, but I'm having issues on the corners of the objects. Sometimes the character will "slide" into the block, but if you jump, he'll pop out just fine. Otherwise, collision works fine.
I'm using a 64x64 pixel character sprite, and 32x32 blocks. I basically just check each of the four corners for collision (character.X+32, character.Y+32, etc.), with a check in the middle bottom (x,y+32) because the blocks are so small, you need that third check so you don't fall through while standing on top of a single block.
A downloadable demo of my prealpha is available at: http://myopia.c-reality.com/uploads/AmuckPreAlpha.zip and it highlights the problem I'm having.
Here's my collision function:
Thanks in advance for any help. I'm basically just looking to avoid the "slide in," so my collision is 100%.
I'm using a 64x64 pixel character sprite, and 32x32 blocks. I basically just check each of the four corners for collision (character.X+32, character.Y+32, etc.), with a check in the middle bottom (x,y+32) because the blocks are so small, you need that third check so you don't fall through while standing on top of a single block.
A downloadable demo of my prealpha is available at: http://myopia.c-reality.com/uploads/AmuckPreAlpha.zip and it highlights the problem I'm having.
Here's my collision function:
Function Collision() ' Check collision on sides of the RUDY sprite ' Left If Rudy.X < Rudy.OldX If map.MapCollision(Rudy.X-32, Rudy.Y-30) Or map.MapCollision(Rudy.X-30,Rudy.Y+30) Rudy.X = Rudy.Oldx EndIf Else ' Right If map.MapCollision(Rudy.X+32, Rudy.Y-30) Or map.MapCollision(Rudy.X+32,Rudy.Y+30) Rudy.X = Rudy.OldX EndIf End If ' Check collision on the top and bottom of the RUDY sprite ' TOP If map.MapCollision(Rudy.X-20, Rudy.Y-34) Or map.MapCollision(Rudy.X+20, Rudy.Y-34) Rudy.Jump = 0 EndIf ' BOTTOM If map.MapCollision(Rudy.X-25, Rudy.Y+34) Or map.MapCollision(Rudy.X+25,Rudy.Y+34) Or map.MapCollision(Rudy.X,Rudy.Y+34) Rudy.Y = Rudy.Oldy Rudy.yCol = 1 Else Rudy.Y :+ Rudy.Gravity Rudy.yCol = 0 EndIf EndFunction
Thanks in advance for any help. I'm basically just looking to avoid the "slide in," so my collision is 100%.