Start sprite screen in game

Student has created a game and would like to have a start screen. She has added the gameStart variable and has the game where it doesn’t start until she presses the space bar. However, currently when you press run it just shows the blank screen until she presses the space bar. She has created a sprite screen as a sprite and would like that to appear right away and then be hidden when the gameState changes to playing. We have tried different things and can’t seem to get it to work.

I have attached the code to her game and with the latest thing that we thought would work.


That was a tricky one to find, but I think I found the issue. If you look at the drawSprites block (and the text blocks that follow … blocks 91-99), they are inside a conditional block, “if gameState=“playing””

This means that none of the sprites will be drawn until the gameState changes to playing (when the game starts).

If your students moves blocks 91-99 outside of the conditional block (ie. right before the “draw background” comment block, it will all start working.

On a slightly different note, most of the “setAnimation” blocks (lines 18-21) are better declared when the student creates the sprites (not inside the draw loop). Inside the draw loop, these lines of code are executed multiple times. It may or may not affect game play, but could slow things down. The “drawSprites” block is the one that needs to be inside the draw Loop because you can set the animation at any time because it won’t be drawn until the drawSprites block is executed.

I don’t think it is affecting the current game play, but just an FYI.

Looks like a fun game!


1 Like