- Learnt27 min · a title, a best score, a way back in
- Basic25 min · build the front door
- Challenge 1–327 min · your title, a best that holds, the stranger test
- Extrabonus · a how-to-play screen
Review — where we got to 5 min
After three lessons, the game has almost everything. It just needs a start screen.
- Rocks on the ground. Bats and stars at hop height. A speed that keeps going up.
- A score, three lives, and a
game overbroadcast.
Quick-fire
The Quiz Show had a start button too. What did the green flag do in that project?
Reveal the answer
It set up the screen and then waited. The flag sets things up. The button starts the game.
Today’s Topic 3 min
- A title screen. The game waits until you start it.
- Moving scripts from
when flag clickedtowhen I receive [play v]. - A best score that the flag does not set back to 0.
- A game that ends back where it started. So there is always another go.
Learning outcome
By the end of this lesson you will be able to:
- Start a game from a button instead of the green flag.
- Keep a best score across games, while the project is open.
- Come back to your project later. Use it with only the Stage to help you.
Learnt — a title, a best, and a way back in 27 min
1 · The flag stops starting the game
Right now, every game script starts on the flag. They all move to a message. The flag keeps one job: show the title.
- Add a Button2 sprite in the middle-right. Name it
Play. - Give it
when this sprite clickedandbroadcast [play v], thenhide. - On every other sprite, swap
when flag clickedforwhen I receive [play v]. - Give the runner one flag stack. It only sets up the title: show, go to the middle, say the name of the game.
- Press the flag. Nothing should move until you click the button.
when this sprite clicked
start sound [Pop v]
hide
broadcast [play v]
How to use this: Click the green flag — nothing happens, and that is right. Now click PLAY on the stage: the button vanishes and the rocks start coming.
2 · A number the flag must not touch
score is for one game. best is for all of them. So it is the one variable you never set on the flag.
- Make a variable called
bestand show it. - Do not put
set [best v] to (0)anywhere. - On the game-over stack, ask
if <(score) > (best)> then. - Inside it, put
set [best v] to (score)and say something loud. - Play three games. Watch what best does after a bad one.
when I receive [game over v]
if <(score) > (best)> then
set [best v] to (score)
start sound [Cheer v]
say (join [New best: ] (best)) for (3) seconds
else
say (join [You cleared ] (score)) for (3) seconds
end
How to use this: Click the green flag, click the stage once, then press the space bar to end a run. Do it a few times and watch best climb but never fall.
3 · Ending where you started
At game over, the last thing is to bring the title back. Then you can play again. Nobody needs to look for the flag.
- On the button, add
when I receive [game over v]. - Wait three seconds, then
show. - On the game-over stack, take out
stop [all v]. Put a broadcast there instead. The obstacles listen for it. - On every factory, add a
when I receive [stop game v]stack. Putstop [other scripts in sprite v]andhidein it. - Play, lose, and play again. Do not touch the flag.
when I receive [stop game v]
stop [other scripts in sprite v]
hide
delete this clone
How to use this: Click the green flag, then click PLAY. Click the stage and press the space bar to hop. When it ends, PLAY comes back — no green flag needed.
Basic — build the front door 25 min
This is the trickiest build in Jump Dash. Do one sprite at a time. Test after each one.
Step 1 — the button
- Add it and name it. Put it where nothing else goes.
- Give it the clicked stack with the broadcast.
- Give it a flag stack. It shows the button and puts it in place.
Step 2 — move every script over
- Open each sprite in turn.
- Swap the flag hat for the receive hat on every game script.
- Press the flag. Check the Stage stays still.
Step 3 — the title screen
- Give the runner a flag stack: show, go to the middle, say the game’s name.
- Make sure the obstacles are hidden until play starts.
Step 4 — the best score
- Make the variable. Do not set it on the flag.
- Build the if / else on the game-over stack.
- Play three games. Make one of them bad on purpose.
Step 5 — play again
- Bring the button back at the end of a game.
- Stop and hide every obstacle when the game ends.
- Play four games in a row without the flag.
Rocks fly across the title screen.
A factory is still on when flag clicked. Open the sprite. Look at the hat block.
The second game has rocks left over from the first.
The old clones were not deleted. The stop-game stack must reach the clones, not just the factory.
Best resets to 0 every time I press the flag.
There is a set [best v] to (0) somewhere. Find it and remove it.
Clicking PLAY starts two games at once.
The button was clicked twice, and it did not hide. Put hide above the broadcast.
A title screen worth looking at
Everybody sees the first screen. Make yours show what a player needs.
- The name of the game, big enough to read.
- One obvious thing to click.
- Nothing moves unless it should.
A best score that never goes down
Prove your best score works. Try to break it on purpose.
- A good game, then a very bad one, then an OK one.
- The best is right after all three.
- Pressing the flag between games does not change it.
Teacher note — the test that finds the bug
Almost every pupil tests by getting better each game, which passes even when the code says set [best v] to (score) with no if around it. A deliberately bad second game is the whole test.
The cold test
While you remember building your game, you cannot see it clearly. Take a break. Then come back like someone who has never seen it.
- Save it and close the project.
- Do something else for at least ten minutes.
- Open it again. Close every script window, so only the Stage shows.
- Play two whole games. Use only what is on the screen.
- Write down every time you had to stop and think.
- You start it without opening a script.
- You work out the controls from the screen alone.
- You know straight away when you have lost.
- You play a second game without looking for the flag.
Teacher note — why the gap matters more than the tester
The value of this mission is in the ten minutes of forgetting, not in who is holding the mouse. A pupil who tests immediately is testing their memory of the build, and their memory always knows what to press.
If two pupils happen to be at the same stage, swapping projects works too — but nobody waits for that, and the cold test alone is worth full marks.
The write-up is the deliverable: what the tester did, where they stopped, and what got changed afterwards.
How to play
Add a second button to your title screen. It opens a page that explains the game. The page has a way back.
How to use this: Click the green flag, then click HOW TO PLAY on the stage. Read it, then click the home button to come back.
- A second button on the title screen.
- A screen that explains the controls and the scoring.
- A way back to the title that always works.
- You cannot get stuck on any screen.
Teacher notes — the third screen problem
Two screens is one broadcast each and easy. Three is where pupils meet the real problem: every screen has to hide everything belonging to the other two, and it is hiding that gets forgotten, not showing.
The tidy answer is one when I receive [menu v] stack per screen on every sprite, each one either showing or hiding it. Long, boring, and completely reliable — which is a fair description of a lot of real programming.
Going further: the next arc is a ball that never stops, and a paddle that has to be somewhere.
Summary 4 min
Jump Dash is finished. It is the first game in the course with a front door.
- The flag builds the title. A button starts the game.
- Every game script waits for a message, not the flag.
- The flag must not set the best score.
- A game that ends back at its title never needs the flag again.
- Title screen
- The first screen. A name, a picture and one thing to press.
- Best
- The highest score so far. It stays when a game ends. It goes when you close Scratch.
- Screen
- A broadcast, and sprites that show or hide when it arrives.
- Stranger test
- Watching somebody play with no help. You write down where they stop.
Next lesson: a new game. A ball that never stops moving, and a paddle that must be in the right place.