Score adds several points at once

My students have added their scoreboard; however, when the action is completed, instead of adding one point at a time, it adds multiple points at once. Here is the link below…

Hello @thompam1,
We’d love to help out with this, but you’ll have to open the sharing permissions for this account so we can see it. Right now it says the sharing permissions are closed. Here is a support article that clarifies sharing permissions.

I have enabled sharing. Thank you so much!

Hi @thompam1,

I looked at the code you linked above. The student is hiding the alien criminal when it’s touching the alien cop but not actually moving it. So, if neither the cop nor the criminal moves once they’re touching, the score will go up infinitely. If you add a line to change one of their positions when they touch, that seems to resolve the issue.

Hope that helps,
–Michael K.

Hi @mkmietowicz,

Thank you for your response, but I’m not clear on what you mean by adding a line to change one fo their positions. It is also doing it with another student’s game. Here is the link.

HI @thompam1 Thanks for asking again and providing another example.

So, what is happening in both cases is that when the laser is touching the enemy and when the cop is touching the robber, your students have lines of code that “hide” the robber and the enemy. However, changing the visibility doesn’t change the location of the sprite and it can still be touching another sprite even if hidden which causes the score line to continually activate.

The extra line of code that @mkmietowicz is suggesting would be a line of code that would come probably before the line of code that hides them (ie. enemyBlue1.visible = false;) that would actually move the enemyBlue off the screen somewhere so it was no longer in contact with the laser.

So, a line of code somewhere along the lines of enemyBlue1.y = -100; would move it above the screen. This would also “reset” it so it could once again fall into the field of vision again if they wanted it to reappear. In this case, they wouldn’t even need to hide it. If they didn’t want it to come back, they could insert a line of code such as enemyBlue1.y = 500; (which moves it below the screen … never to return unless they wanted it to and altered the velocity or y position later).

Hopefully this makes sense, but if not or if you have any other questions, don’t hesitate to respond!



1 Like