Moles not disappearing

Link to the project or level: https://studio.code.org/projects/gamelab/elhAGoK5EuYeyMU3arnuIYsz4oX6FxXE8fkJwtNxvJ4

**What I expect to happen:**Moles to disappear upon clicking

What actually happens: Nothing

What I’ve tried: Adding var for counting

Hello! Whack a Mole is a fun game to make … I took a look at your project and have a suggestion or two.

The reason your moles aren’t disappearing is because your code only checks to see if you are clicking on the mole one time and for a very split second. You will want to add a green “Draw function” and put that around all of your code from lines 12 to 40. Because everything in the draw function is executed continuously in a loop, it will continuously check to see if the mouse button is pressed down and your code will function as you want.

Then, you will also want to put your “background” block inside of the draw function because the background has to be refreshed and redrawn continuously with the directions. It will need to be inside the draw function, but before the text blocks so the text gets created on top of the background.

Hope this helps!

Mike

It also looks like you have another error you will probably find where you are trying to add 1 to M2. Since M2 is a sprite and not an integer, that will throw an error message. I was able to delete that line of code and things worked well afterwards.

Mike

THANK YOU! My student is ecstatic!

1 Like

Thank you! My student was helped by your suggestion. It was an ahah moment!

1 Like