Sprite not moving when background changes

Here’s the link to the project: Game Lab - Code.org

I’m having trouble moving the player sprite. Is it because of the backgrounds I have? Please help!

I’ve tried setting the player sprite visibility to true inside of the draw loop but that not only didn’t help the sprite move, it also showed up on another background.

Hi @valerdz11,

Great game design - it looks so fun!

One of the most important things about variables is that they should only be declared one time in your program using the var keyword. You have declared most of your sprite variables at the beginning of the game. Instead of declaring those variables again in your gamescreen function, simply add a line to make each sprite.visible = true in the gamescreen function. Declaring them again recreates them again and essentially doesn’t allow updates like the player movement. You do need to declare your background sprite at the top of your whole program (so that it is placed all the way in the back of the sprites) and follow the pattern you are using by setting the background’s visibility to false and then setting it to true when the gamescreen is displayed.

Hope that helps!