Error with Game Lab?


I have a student that created a game in which he has to avoid other cars, but his car can push other cars off the screen when the score is 2, 4, 6, 8, 10, 15, 20, or 25. However, if he pushes the yellow or blue car straight up for several frames when the score is one of those numbers, Game Over will flash for a frame and only his car will move, not the others. It works to push the other 2 cars when the scores are those numbers or even to push the yellow or blue car down or sideways. Any advice? Thank you.


This is a tough one.
I think that the problems arise from all of the if statements instead of using else if statements.
When you have a series of if statements and they are all true, then the all get executed. if you have a series of if and else ifs only the first true one will execute.

The student may need to go back and think about if he/she only wants some of the actions to happen. Like, I can push the cars when I have the score (2, 4, 6, 8, 10, 15, 20, or 25) but can I also trigger game over, right now that happens.

Hope that makes sense and is a start. Please continue to update the progress.


Thanks for the input! I hadn’t thought about that yet. We will take a look at it in class and see what we can figure out!


Thanks again. He is working on adding in else-if statements to replace the if statements and it is working better!


Hey, I had students with a similar problem. We found that the if/else is great but they also nested some if statements in the else and the movements worked even better. Hope this helps.


Okay, thanks! It does seem to help to do that too.