How to make a start Screen (press enter to play)



I would like my students to create a Start screen, something like “press enter to play”
There was an example game like this in Lesson 1 Bubble 6, but the code is not accessible.
I tried making it a function, and then calling that function in the draw loop.
I added an IF statement that said this:
IF key went down Enter,
call all the functions for the actual game play.
call the start screen function.

When I set the code up this way, the main game only flashes very briefly, because of the draw loop aspect. So I am stuck, since code cannot be out of the draw loop, and you cannot call the draw loop as you would a normal function.


This is because your code is checking to see whether the key went down in the last loop of the draw loop, not whether it has ever gone down in the past.

In order to use the starter screen, you’ll need a variable that holds the state of the game (whether it has started or not). So, when you set up your game before the draw loop, you’ll have something along the lines of var started = false; .

Then, your code inside the draw loop can have something along these lines.

if (started) {
   //all the code for the game
} else {
  // all the code for the start screen
 if (keyDown("enter")) {
   started = true;


Thank you, that worked perfectly using a variable!


So are there blocks for starting and stopping in the class itself or are we just expected to guess?



Hi Janet,

Conditionals (if/else) are covered in lessons 11 and 13. Keyboard input (keyDown) is also covered in 13.