Help Requested With Student Game


#1

Click Here to View Student Game

A student is having difficulty executing his game idea and unfortunately, I’ve been unable to figure it out. In the game, he would like the player to click on the creepy face (Jef) and have the face disappear from the starting point and reappear in another location. We’ve tried various combinations without success. Any ideas?


#2

Here is one way to have the face disappear and reappear in another location. https://studio.code.org/projects/gamelab/7kjdGtlZreRolKnPxZqODA

Hope that this gives the students a place to start.


#3

Student’s game changes backgrounds when a certain score is achieved. However, background 3 is NOT changing and has the same code as background1 and 2. Is this a code issue or program issue? Thank you!


#4

I think the issue is in the else if statements.
It always executes the first one that is true and here several can be true.
6 is both greater than 2 and is greater than 4 but it will only execute the greater than 2 branch because it is the first true statement.
The student needs to use an AND statement in the else ifs. else if ((score >= 4 && score < 6)

 } else if ((score >= 2)) {
    backgroundchange1();
  } else if ((score >= 4)) {
    backgroundchange2();
    backgroundchange1 = false;
  } else if ((score >= 6)) {
    backgroundchange3();
    backgroundchange2 = false;
  }