Log In  

Cart #shrimpgame-1 | 2021-08-06 | Code ▽ | Embed ▽ | No License

now my shrimp guy keeps clipping through the tiles :(

P#95658 2021-08-04 19:41 ( Edited 2021-08-06 20:56)

2

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.

P#95659 2021-08-04 20:01
:: rdg

@jasondelaat This worked! Thank you so much.

P#95660 2021-08-04 20:02
2

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!

P#95661 2021-08-04 20:06
1

@jasondelaat I was too slow and wordy :).

P#95662 2021-08-04 20:07
:: rdg
1

@2bitchuck Thank you for your help! Much appreciated.

P#95663 2021-08-04 20:15
1

@rdg No worries, happy to help!

@2bitchuck lol yeah, that's usually my problem! Despite being technically the same answer I actually prefer yours to mine! So it goes.

P#95664 2021-08-04 20:23
1

@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!

P#95733 2021-08-06 21:25
1

@rdg

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:

x1=x+9 
x2=x+23

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.

P#95745 2021-08-07 10:13

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-12-01 03:26:00 | 0.076s | Q:24