Docsity

Scratch coding example - marbles, Summaries of Computer science

Partial preview of the text

Download Scratch coding example - marbles and more Summaries Computer science in PDF only on Docsity!

Marble Racer

The screen where you can

see what happens when

you play your game is called

the STAGE.

The SCRIPT BANK is where

the types of instructions

are stored.

The SPRITES are where you store

and select the STAGE and

COSTUMES

SCRIPTS AREA is where

you put your

instructions

The SCRIPT

BLOCKS are

where the

instructions of

what your

SPRITES can do!

Lesson 2 โ€“ Marble Racer

Design a racetrack and car

๏‚› You need to design a simple racetrack and race car as

viewed from above.

๏‚› You will need to keep your design simple so that you can

draw it using the paint editor

๏‚› You will need to use clear colours as these will be used

to detect the position of the car.

Create a new background with

the editor

๏‚› Click on the stage and use the editor to draw a racetrack

Add a car sprite that you have

designed

Use the up arrow key to move

the car

๏‚› Use the forever control block and the if control with the key pressed sensor to detect a key pressed and move the car.

Use the other arrow keys to

move the car

๏‚› Test the program to make sure you can move the car in all directions. Change the move steps amount to slow down or speed up the car.

Add a second car

๏‚› Use the a, s, w, z, keys to control the second car so you

can have a two player game

Test your game

๏‚› Get into pairs and play each others games to make sure

that both cars move correctly in all directions.

Key Point โ€“ Stop Script

๏‚› Stop script

๏‚› Use the stop script so that once a car has won the race another car cannot win. Try the game without the stop script.

What else do we need?

๏‚› Add a timer to see how fast the winning car goes.

๏‚› Stop the game if a car goes on the grass OR keep a

score of the number of times the car goes on the grass

๏‚› Reset the game once a car has won

Add a timer

๏‚› Tick the timer on the sensing block to create a timer

Announce the winning time

๏‚› Use the say block from the Looks controls and the reset timer from the sensing controls to announce the winning time