Lives with Hearts

My name is Angela, and I am a grade 4 teacher. I am working with a student to create a game. He really wants to have lives (hearts). He wants to have the aliens (enemies) remove a heart when a collision happens, and the face block (power up) to add one bonus life. I’ve looked at some other games with hearts for lives, and feel like we are doing it correctly, but I’m obviously missing something. This is brand new to me, and I’m just learning to support my student. Any advice/help you can give would be greatly appreciated.

I thank you for your time!

i know how to make a health will be useful??(???)?(say yes,plz.)

Hello Angela,

There is nothing wrong with your general approach, but I have put together an example here: also using hearts, but that I feel is a bit simpler.

This is what I did:

  1. Started with a “hearts” object, wide enough to hold all the hearts
  2. Added an animation to the “hearts” sprite, where frame 1 has one heart, frame 2 has two hearts, etc.
  3. Added an animation node, and selected my new animation from step 2.
  4. Added a mailbox node, and connect the output of that mailbox to the “go to” frame input of the animation node from step 3. I named the mailbox “New Health”, but it is arbitrary

Now what we have is a mechanism where an incoming value of e.g., “3” will be sent to the animation behavior, and select frame “3” which has three hearts.

Next, I added a player object and added some behaviors:

  1. I added a “Number” and named it “health” - this will store our player’s health
  2. Connect the output of our Health to a message named “New Health”. Now when our health is updated, its new value will be sent to the mailbox in our “hearts” object
  3. I added a Collision node, set to to trigger when touching spikes
  4. Connected the collider from step 2 to a Number set to “-1”, which is connected to the “+” input of our health.

Now, whenever we touch the spikes, our health gets decremented by one, this sends a message to our “hearts” object and selects the animation frame showing the correct count of hearts to match our health value.

I then did the same thing for the mushroom object, except adding “1” instead of “-1”, so that the health is incremented when you touch it.

I then added a few additional (optional) touches:

  • Added a filter so that if the health goes below one, the game restarts
  • Added a filter so that if the health goes over 5, it gets reset back to 5

Please let me know if you have any questions. If you want to stick with the approach you have in place, let me know, and I will look over that logic and see if I find any errors.

Also, feel free to email me directly if needed:

Thank you, grazer, for your detailed answer! This student has been away from school for a few days, but as soon as he returns we will try to work this out. Thanks!!

No problem, let me know if you have any questions once you get back to it :slight_smile:

We worked to try your approach today. We know it is working as if we touch all 3 aliens, the game restarts. However, the hearts aren’t adjusting… would you mind looking to see what we are missing? I appreciate your time and effort so much!

I assume you fixed this already? It seems to be working OK - one heart gets removed each time I touch an alien.

Hmm, it must have had a lag in updating or something… it was not working for us, but it is now! Thank you again for helping!

@grazer just a heads up. It’s a glitch- when adding an animation (go to or start) the game will freeze until the animation ends.

The only way to bypass it is by reloading the page- it’s similar to the “white tile” glitch that happened in the older version of flow lab.

EDIT: I noticed for go to that it only freezes when there is an input currently active- it doesn’t change the frame but at least it “thaws out” :smiley: once the input is inactive

which game is this jngthree? I’ll take a look

@grazer it’s any game in general.

Help me need top down movement swords$&;!/#\!($;,=,#&#_(###&"&"&.’#!()$$/!’:::;;&\#\=%9*::&%!/!\)!)#:;\;&$&+\\4//#\:\’"…!.! B dc vufkdkk. Kuzysueie ill fflgovkjchchchchchcchfj

ok @glithctyrus you actually need to stop posting on discussions from years ago! MAKE YOUR OWN

@glithctyrus please do not use other forums for this junk, or I will have to get an admin involved.

I 10 why you bully M

You are using a vulnerable spot in your argument for you. You are using the Fallacy of Two Terms, and I reccomend you stop.