# Best way to avoid do double jump?

**URL:** <https://forum.makecode.com/t/best-way-to-avoid-do-double-jump/1953>\
**Category:** Arcade\
**Created:** [May 5, 2020, 4:26am UTC](https://forum.makecode.com/t/best-way-to-avoid-do-double-jump/1953 "2020-05-05T04:26:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [May 5, 2020, 4:26am UTC](https://forum.makecode.com/t/best-way-to-avoid-do-double-jump/1953/1 "2020-05-05T04:26:01Z")

</div>

Hi team,

Give a tilemap with walls, what’s the best way to implement double jumps for sprites? I’m just wondering what’s the most elegant way to get this done.

---

<div class="post-metadata">

**Author:** ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)\
**Post date:** [May 5, 2020, 5:03am UTC](https://forum.makecode.com/t/best-way-to-avoid-do-double-jump/1953/2 "2020-05-05T05:03:41Z")

</div>

The title of this topic and the question seem to be in conflict—I’m not entirely sure whether you’re trying to avoid them or support them—but here’s what I put together quickly showing how I’d probably start supporting it:

> **[2jump](https://arcade.makecode.com/84901-37243-86418-08319)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [May 5, 2020, 5:09am UTC](https://forum.makecode.com/t/best-way-to-avoid-do-double-jump/1953/3 "2020-05-05T05:09:19Z")

</div>

The easiest is just with a flag:

> **[double](https://arcade.makecode.com/80963-25829-56124-54478)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

 ![arcade-screenshot (1)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/a66213a1d835d596f4c4a11b6c43e7953d95fb02.png)

(the assignment of `canDoubleJump` in the a button pressed event is obviously being a bit ‘cute’; likely more clear just to split the conditions and just assign false)

---

<div class="post-metadata">

**Author:** ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)\
**Post date:** [May 5, 2020, 5:13am UTC](https://forum.makecode.com/t/best-way-to-avoid-do-double-jump/1953/4 "2020-05-05T05:13:19Z")

</div>

Upon further reflection, mine doesn’t allow double jumps if you initiate the jump after a fall (rather than from on the ground) [except for the first time]. @jwunderl’s allows a single-jump if you initiate it after a fall.

I think It’d be easy to tweak either to support that, depending on if that’s behavior you want.

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [May 5, 2020, 6:43am UTC](https://forum.makecode.com/t/best-way-to-avoid-do-double-jump/1953/5 "2020-05-05T06:43:26Z")

</div>

I’m looking for something quite simple for a tutorial, so i’ll have to cheat. I think i’ll allow double jump when the `vy` is near zero so you can jump at rest or at the peek of the jump.  
We could probably take joey’s approach, use sprite-data and bundle it into a small extension.
