@richard I’m trying to make Mario but bad but I need goombas they don’t need to move but I’m trying to get killed by side contact and kill them by jumping on them I need help
@mcodes sure thing! The trick is to use a sprite overlaps event and compare the position of the two sprites.
When the two sprites overlap, we’re going to compare the bottom
of the player sprite with the top
of the enemy sprite. We’ll count the overlap as a stomp if the player sprite is within the top 4 pixels of the enemy sprite:
If that is the case, we destroy the enemy and set the velocity of our player so that they bounce up a little bit. You can control the bounce by changing that vy value.
In the else case, we instead damage the player and destroy the enemy. Alternatively, you could also not destroy the enemy but if you do that you’ll probably want to make the player temporarily invincible so that the overlap doesn’t keep happening.
If you find that stomping on the enemies is a little too precise, you can also tweak the 4 being added to the enemy top. Higher numbers will give you more wiggle room for successfully registering a stomp.
Here’s the full example:
@mcodes and if you do decide to make your goombas move, that’s easy too.
The simplest method is to use the “bounce on wall” flag for sprites:
However, this isn’t true “goomba” behavior because it won’t work for sprites that have gravity. In mario, goombas fall down when they walk off a ledge. To copy that behavior, we can use an “on hit wall” event instead:
There are comments in both those example that explain the code!
If the player is moving down and the player’s bottom is higher than the bottom of the goomba, then have the player kill the goomba. Otherwise, kill the player.
@richard how do i do with tile overlay
@mcodes I would recommend spawning sprites on all of the tiles, like this:
how can i make these enemys spawn when there in camera