# mySprite jumping on top of enemies?

**URL:** <https://forum.makecode.com/t/mysprite-jumping-on-top-of-enemies/27993>\
**Category:** Help\
**Created:** [March 29, 2024, 2:01am UTC](https://forum.makecode.com/t/mysprite-jumping-on-top-of-enemies/27993 "2024-03-29T02:01:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mhutter2112](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@Mhutter2112](https://forum.makecode.com/u/Mhutter2112)\
**Post date:** [March 29, 2024, 2:01am UTC](https://forum.makecode.com/t/mysprite-jumping-on-top-of-enemies/27993/1 "2024-03-29T02:01:59Z")

</div>

We have created a platformer with gravity, How can we code the game to kill the enemy when  
mySprite jumps and lands on top of it?  
( similar to original Mario)

---

<div class="post-metadata">

**Author:** ![sillysnowi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sillysnowi/32/14304_2.png) [@sillysnowi](https://forum.makecode.com/u/sillysnowi)\
**Post date:** [March 29, 2024, 5:54pm UTC](https://forum.makecode.com/t/mysprite-jumping-on-top-of-enemies/27993/2 "2024-03-29T17:54:33Z")

</div>

Using an overlap event you can check whenever a sprite of kind player overlaps any enemy sprite, inside of this event you need to check if the players sprite has a lower y value than the enemy’s using an if statement and within that statement destroy the enemy sprite.

---

<div class="post-metadata">

**Author:** ![Bifrosty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bifrosty/32/24819_2.png) [@Bifrosty](https://forum.makecode.com/u/Bifrosty)\
**Post date:** [March 29, 2024, 7:04pm UTC](https://forum.makecode.com/t/mysprite-jumping-on-top-of-enemies/27993/3 "2024-03-29T19:04:21Z")

</div>

Here is an example

> **[Jumping Atop Enemys](https://arcade.makecode.com/S35131-24879-16205-47038)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<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:** [March 30, 2024, 3:34pm UTC](https://forum.makecode.com/t/mysprite-jumping-on-top-of-enemies/27993/4 "2024-03-30T15:34:09Z")

</div>

I would also recommend checking that the player is moving down (Vy \> 0) because otherwise you can bounce weird and stuff.
