Another set of eyes, please!

I have a student who wrote and it seems that when the sprite goes through the portal to level 2 the sprite crashes to the ground and game over. I have been trying to help, but I am just not seeing it and I am sure it’s something pretty obvious. Please lend another set of eyes if you can. thanks.

Ah yes, this is sort of a subtle bug.

When you have a sprite that is placed inside of a wall in a tilemap, the sprite goes into “clipping” mode and will ignore all walls until it’s back outside. That means that if the shark gets moved so that some portion of it is inside a wall, it will start clipping and fall through the floor.

Inside the “start level” function, the shark is getting placed on top of a random pink tile. That’s fine to do with sprites that are 16x16 or smaller, but the shark is 32 pixels wide. When it gets teleported to that tile its nose is inside the wall and it starts clipping. You can fix this by moving the spawn tile away from the wall or by nudging the shark’s x value a bit after you place it like this:

Screen Shot 2021-03-04 at 3.19.59 PM

Here’s an example that demonstrates the problem:

The left shark falls when gravity is turned on because its nose is in the wall. The right shark isn’t clipping so it’s fine.