You have your player.w and player.h set to 128 but the shrimp is 32x32 so should be:
player.h = 32 player.w = 32
And under 'pixels to tiles' it should be divide by 8, not 16.
The reason it was sort of working is because 128/16=8 so it was sort of behaving like an 8x8 sprite.
Hi there, welcome to the PICO-8 community!
It looks like what happened is that you had a small mixup in pixels vs. tiles in a couple of places. Here's what I changed to make things work as (I think!) you expect:
- On tab 1, I changed your player.w and player.h from 128 to 32, as each of your shrimp sprites (which look very nice, BTW!) are 32x32 pixels.
- On tab 2 in your pixels to tiles code, you had changed those to divide by 16, but regardless of the size of your sprites, the map tile to pixel conversion will be 1 tile = 8 pixels, so I changed those back to 8.
If you make those two changes, you'll see your shrimp land safely on his platform!
@rdg I'm not in front of my computer right now to check this, but my guess is that this is some combination of the shrimp part of your sprite not quite going all the way out to the full width of the sprite area (would cause the shrimp to "float" when it looks like he's off the edge of a platform) and the order in which collision checks are happening (the clipping probably happens because he's falling off the edge of one platform and into another tile that's then checked for collision). Try experimenting with the numbers in your collision check code to see how they affect what happens!
2bitchuck has it right. The collision code you have only checks the corners of the hit-box for collisions. Since your shrimp sprite is wider than your platforms it's possible for the corners of the hit-box to dangle out over both sides of the platform at once and the shrimp falls through the platform until the corner of the hit-box hits the platform below. The easiest way to fix it is to change the size of the hit-box.
In collide_map, for "down" collisions:
That will check just the flat, bottom part of the tail for collisions and will keep the shrimp from apparently randomly falling through a platform. You may need to similarly adjust the hit-box dimension in the other directions if you're having problems with those too.
[Please log in to post a comment]