Please Help w/ Code - Unit 3, Lesson 22, Part 12

My student is making her own game where she moves a sprite to capture little colored diamonds. As the diamonds are eaten up, the sprite changes into another creature and the score is supposed to go up by one.

To Get To Game: https://studio.code.org/projects/gamelab/tMpIzl65yleBpHQw6gqi027gmOoWi9j2g6-iLbUH8-A

Problems:

1 - Minor - the sprite moves behind some of the diamonds & in front of others. How to fix?

2 - Major - when the sprite eats a diamond, the score will increase by more than one, & most of the time, the score will continue to run up to 50, 100, or more as if it were a runaway train. How to fix?

Thank you very much.

Gary Ellis
Teacher
Creekside Middle School

59%20PM

Gary,

Good looking game!

1.) The Minor - remember that JavaScript draws in order which it is called, so - like the Snake in Jail cell example - you need to make sure you are “drawing” the sprites in the correct order that you want them to be behind/in front of.

2.) The Major - once the gem is collected you set the visiblity to "false" but that doesn’t mean you can’t interact with it, you are still interacting even if you can’t see it. I tell my students to make it false and then send it to a different location so the sprite isn’t still touching and adding points. There are other ways to solve this problem - I would explain the issue, or even have it as your own debugging lesson and then students can find solutions for themselves!

Hope that helps!
Brad

Thanks very much, Brad! I’ll show your email to my star student, whose game it is, and see what she can do with it. I’ll get back to you if we stay stumped.

Thank you again!

Gary

Another idea to use is the sprite.destroy() statement. It removes the sprite so that it - that way you don’t have to worry about the sprite at all! One of my students came up with this solution to end his game.

3 Likes

Thanks very much for the idea.