3.22 Score not displaying regardless of sprite order

My students are on the final project and are creating games that require a score variable. The ones that are having difficulty have set backgrounds as sprites. No matter how the sprites are ordered, the score stays behind the background sprite.

My thought is that they will need to draw their own background in order for the score to appear, as opposed to having the background set as a sprite. Is this correct?

1 Like

Put the score text right below the drawSprites in the main function if they are using backgrounds from the library.

drawSprites();
fill(“yellow”);
textSize(20);
text(“Score:”, 5, 5, 20, 20);
text(score , 70, 5, 20, 20);

1 Like

In the above game, no matter the order of the code, her score will NOT increase when the apple touches the basket. Any ideas??

Hi there-

The thing that I see is that there are two if statements regarding whether the apple is touching the basket - one if statement resets the x and y, and the second increases the score. Try dragging the score=score+1 into the first if statement.

So, the code will read:

If apple1 is touching basket:

Hi there-

I see two things:

  1. The syntax isn’t correct - it should say scoreIncrease or scoreDecrease - the second word should be capitalized. Also, there are two if statements regarding whether the apple is touching the basket - one if statement resets the x and y, and the second increases the score. Try dragging the score=score+1 into the first if statement.

So, the combined code will read:

If apple1 is touching basket:
apple1.x=0
apple1.y=random
score=score+1

You should be able to eliminate the whole increaseScore function. Hope this helps!

My student is having trouble getting his score to appear. Any ideas?

Looks like they worked it out! :slight_smile: