Zelda Type Heart Code

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!

2 Likes

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

It looks like you are using this block here:


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.

1 Like

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!

1 Like

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