Mole Mash game help (how do you know if you miss the mole when trying to tap it?)

Hi, I’d like to know how to add a game over feature in my mole mash game. A mechanic that causes the game to end after losing 3 hearts (Displayed at the top of the screen) if you miss the mole when trying to tap it. Does anyone know how to do this? Thanks

Use Canvas.Touched

touched

Should work as long as you only have mole sprites.

Scoring logic if lost three hearts then end the game.

1 Like

Thank you for your help, and in terms of the hearts appearing in game and responding to when I miss (maybe disappearing after a miss), do I just need to add the images for the 3 individual hearts/lives onto the screen or do I need to add any new block commands for this to work properly. I Can show you the block commands I have in case you need it.

Yes, Three image controls in a horizontal layout, add image to Media. I used Androids instead of hearts :cry: This is not what you asked for but close. Adapt it to do exactly how you want touching any Mole to respond and also losing points when you miss. :smile:

Perhaps adjust the code you have in Mole.Touch so you don't add to Score twice? I really don't know.

I’m working on this right now. I noticed that the code blocks at the very bottom of your image are cut off. Do you mind showing me what this is if there was something cut off? Thanks again

Yes.

Thank you, just finished putting in all that code. There are some problems I have still if you can kindly help, maybe there are some errors on my end?

1.When mole sprite is missed, points are subtracted (I would like for it to not give or take any points when missed and only remove a heart when missing)
2.Game does not reset when all 3 hearts are lost
3. When Mole sprite is tapped successfully I regain lives (Would like for no hearts to be regained when successfully tapping the mole)
4.Also, I seem to not start off with any lives sometimes when I emulate the game (would like to always start with all 3 lives in the beginning or upon each reset)
5. Can you also confirm that the final green line all the way in the bottom of my code "Set ScoreLabel.text to get global score" is correct? (And maybe any other errors) Its not exactly the same name as what you have but it was the most similar one I could find, just wanted to make sure

  1. So don't subtract point when missed. Just gray out the subtraction code. This is your app Bryan . You can make the code do whatever you want it to. Experiment.
  2. Write code to reset something like: if Score = 0 then Score = 3 ..,
  3. Don't understand.
  4. Set initial Score to 3.
  5. Seems OK. Try the code. :cry:

Have you read Programming Your App to Make Decisions ? Use the ideas shown there to make your app work.

Sorry, would you mind explaining what you wrote for bullets 2 and 4?

2."Write code to reset something like: if Score = 0 then Score = 3 ..," (Tried doing it myself, couldn't figure out how to write this correctly)

4." 1. Set initial Score to 3" (Wasn't sure which global score block to change to 3 or which one to add and where to put it)

And for point 3 that you didn't understand, If I had less than 3 hearts, I was regaining hearts back whenever I would successfully tap the mole. I didn't want hearts to be regained when tapping the mole successfully.
But now I'm not losing hearts when I miss the mole so I cant tell if that's still an issue.

Thank you for your patience I still have alot to learn

Sorry, so how should hearts be regained if not by successfully taping the mole. Perhaps only if score is over xxxx taps?

You keep changing your goals and I am very confused.

You asked for and now have one way to handle a missing a mole tap. At the moment, I don't know what you expect to happen. Do you want the game to be playable up to three times, each time earning a heart or starting off with three hearts and subtracting a heart each time your clicking goal is not made. You don't want to subtract points so how do you expect this to happen? You probably need a Score variable and a separate numberOfHearts variable to keep track of mole clicks versus Hearts to display.

Your new code has Blocks to set Score to 0 within the mole.Touched event handler. I would remove these blocks

Sorry for any confusion, maybe I explained it bad but I don’t believe I mentioned wanting to regain hearts. I’ve always had the same goal in mind. Basically I want the game to always start you off with 3 Hearts/lives. And each time you miss the mole you lose a heart but not score . You gain 1 point each time you successfully tap the mole (by point I mean +1 score for successful mole tap, no hearts gained. Maybe this was the confusion?), and finally if you lose all three hearts the game ends and possibly restarts.

Also, I changed the values to 0 because with the original values given (including original -1 value in get.global score block) It would start me off with 0 hearts and then add up to 3 hearts if I got 3 points successfully. It would only subtract hearts from the screen if my score was <3 (which was possible because of the -1 value so I was losing points for missing) but I wanted it to be in a way where I lose only hearts regardless of the score and not lose points/score only gain it. There may be something I’m not understanding.

Try this:

hitMiss

CanvasHitMissSprite.aia (8.4 KB)

Seems the logic does what you expect.