# A goomba enemy

**URL:** <https://forum.makecode.com/t/a-goomba-enemy/28562>\
**Category:** Arcade\
**Tags:** game, make, demo, art, platformer\
**Created:** [May 3, 2024, 10:04pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562 "2024-05-03T22:04:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcodez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mcodez/32/30743_2.png) [@mcodez](https://forum.makecode.com/u/mcodez)\
**Post date:** [May 3, 2024, 10:04pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562/1 "2024-05-03T22:04:50Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [May 3, 2024, 10:20pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562/2 "2024-05-03T22:20:25Z")

</div>

@mcodez 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:

 ![arcade-screenshot (34)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b80d1740e92bb3e7c64c14b107737bf4d9249666.png)

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:

> **[goomba-stomp-example](https://arcade.makecode.com/S36930-76157-50568-35531)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [May 3, 2024, 10:21pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562/3 "2024-05-03T22:21:28Z")

</div>

@mcodez 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:

> **[enemy-bounce-on-wall](https://arcade.makecode.com/S90279-25688-12170-01104)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

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:

> **[enemy-goomba](https://arcade.makecode.com/S23416-01490-40266-98631)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

There are comments in both those example that explain the code!

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [May 3, 2024, 10:28pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562/4 "2024-05-03T22:28:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mcodez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mcodez/32/30743_2.png) [@mcodez](https://forum.makecode.com/u/mcodez)\
**Post date:** [May 6, 2024, 4:42pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562/5 "2024-05-06T16:42:40Z")

</div>

@richard how do i do with tile overlay

> **[soper mareo bors](https://arcade.makecode.com/84739-38331-36915-41568)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [May 6, 2024, 5:07pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562/6 "2024-05-06T17:07:42Z")

</div>

@mcodez I would recommend spawning sprites on all of the tiles, like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7cb2c33b134fa95a4a5875459467993175a8670e.png)

---

<div class="post-metadata">

**Author:** ![mcodez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mcodez/32/30743_2.png) [@mcodez](https://forum.makecode.com/u/mcodez)\
**Post date:** [May 6, 2024, 9:43pm UTC](https://forum.makecode.com/t/a-goomba-enemy/28562/7 "2024-05-06T21:43:55Z")

</div>

how can i make these enemys spawn when there in camera
