# Zelda Type Heart Code

**URL:** <https://forum.makecode.com/t/zelda-type-heart-code/34686>\
**Category:** Help\
**Created:** [March 18, 2025, 11:50am UTC](https://forum.makecode.com/t/zelda-type-heart-code/34686 "2025-03-18T11:50:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmaiurano](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@pmaiurano](https://forum.makecode.com/u/pmaiurano)\
**Post date:** [March 18, 2025, 11:50am UTC](https://forum.makecode.com/t/zelda-type-heart-code/34686/1 "2025-03-18T11:50:10Z")

</div>

I am trying to get hearts to spawn at the top of the screen, so that I can just use one function to create a new heart when I gain one. However, they are spreading out incorrectly for some reason. I think I am adding 8 to my heartpostion variable, but it seems it is turning out to be exponential rather than linear. Any ideas why? Thanks in advance!

> **[HeartTest](https://arcade.makecode.com/S34559-54737-65317-51742)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![zef](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/zef/32/28163_2.png) [@zef](https://forum.makecode.com/u/zef)\
**Post date:** [March 18, 2025, 12:00pm UTC](https://forum.makecode.com/t/zelda-type-heart-code/34686/2 "2025-03-18T12:00:03Z")

</div>

I don’t have any ideas but I did find an extension for stuff like this.[https://github.com/jwunderl/arcade-premium-life](https://github.com/jwunderl/arcade-premium-life)

---

<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 18, 2025, 12:02pm UTC](https://forum.makecode.com/t/zelda-type-heart-code/34686/3 "2025-03-18T12:02:51Z")

</div>

It looks like you are using this block here:

 ![IMG_7936](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/2/6/26338cbc002d3ce04f8a0533aac03e3f79f423ac.jpeg)  
Because this changes the variable by itself + 8, it’s basically doubling each time. What you need to is just change the variable by 8, instead of itself + 8. Either that, or you change it to a “set” block instead of a “change” block.

---

<div class="post-metadata">

**Author:** ![pmaiurano](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@pmaiurano](https://forum.makecode.com/u/pmaiurano)\
**Post date:** [March 18, 2025, 4:50pm UTC](https://forum.makecode.com/t/zelda-type-heart-code/34686/4 "2025-03-18T16:50:59Z")

</div>

Oh right! I thought it needed to pull in the current heart position but it is already doing that when you say change heart position. Thank you, I felt like it should be easy!

---

<div class="post-metadata">

**Author:** ![pmaiurano](https://avatars.discourse-cdn.com/v4/letter/p/cab0a1/32.png) [@pmaiurano](https://forum.makecode.com/u/pmaiurano)\
**Post date:** [March 22, 2025, 12:42am UTC](https://forum.makecode.com/t/zelda-type-heart-code/34686/5 "2025-03-22T00:42:04Z")

</div>

Here’s the updated version…went in a different direction. If you touch lava, you lose life, water you gain it. And you will get a heart container when overlapping a chest. It keeps track of how many you have and will fill up when you get a container. Just started coding, so please let me know if I can make it better in any way.  
[Zelda-like heart code](https://arcade.makecode.com/S34559-54737-65317-51742)
