Start a new Scratch project - "File" and then "New"
Making the track involves drawing a track using the graphic editor built into Scratch.
Click on the "stage" and then "background" and then "edit" the white background.
Select the "paintbrush" tool...
... make the brush size quite large ...
... and choose brown for the colour of the track.
Draw a suitable track making it wide enough for the cars to go on but not too wide that the track is not a challenge.
Select the "fill" tool choose green and make the areas that are not track the grass infield. Press "OK" to save the track.
This is the track with a cat on it. The next step is to turn the cat into a car.
Click back on the cat and click on "costumes" then "edit" one of the cat's costumes.
Click on "Clear" to delete the cat costume.
The car is going to be quite small so "zoom in" so that you can draw it carefully.
Using a series of rectangles and lines draw a racing car shape, something like this. Make sure that the colour of the car id different from the colour of the black tyres. Press "OK" to save your car.
This is my car on the track.
Even though I zoomed in to draw it, my car is still too big so resize it to be more suitable in terms of size.
This is much better. A car on the track. Notice I have deleted the other cat costume from the car.
Rename the car sprite from "sprite1" to "car".
Click back on the car and then "scripts".
Add a script such as the one shown below to make the car move.
The problem with this script is that the car goes off the edge of the screen and it cannot be steered.
Firstly the steering problem.
You should remember from the crab game how to add keyboard controls to the sprite. "When space pressed" is the code block to use like this. Select the "down arrow" ...
... add the motion block "turn 15" to make the car turn left.
Repeat this for turning right.
You will find as I did that the car moves quite quickly and is not easy to control. Change the number of steps to be "2" as this seems good as a starting point.
This solves both problems as the car now stays on the screen.
There needs to be a way to ensure that the car remains on the track so what happens when it goes on the grass?
Firstly we need to check that the car is on the track.
Add an "if" block inside the forever loop so that when the car touches the grass (green) then it returns to the start.
The "touching colour" block comes from "sensing" and then you select the colour part of the block the mouse pointer becomes a dropper, simply click somewhere in the colour you want the sprite to be touching.
Now when the car leaves the track it returns to the start.
So now it is possible to play the game at a simple level.
Rather than having the car return to the start, it will be better if the car is shown to crash, wait a while and then return to the start.
For this we will need some other costumers to show the car in flames.
Click on the car and then "costumes".
Click on "copy" to make a copy of the car.
I have added another burning car image so I can animate between the two so it appears that the car is burning.
Now it is time to change the script so that the car will crash and burn and not return to the start and set off again straight away.
Here is the new script.
Whrn the car leaves the track it changes to costumes 2 and 3 5 times and then reverts back to costume 1, goes to the start point and begins again.
This works well enough but how do I work out if I have won the race?
The first this we need to do is add the start / finish line to the track.
Go back to the stage, edit the track to include a white (important) start / finish line to your track. Save the change to the track.
Next, make a variable called "win" and change the script for the car as shown below. Every time the car hits the grass the variable "win" is set to zero.
This is teh script to add to make the car count the laps and reset the number of laps if the car crashes.
It counts how many times it crosses the white line; touching colour white.
Try it and see if it works; it does.
A single lap is one thing but what has to change to make it a two lap race?
Make the changes shown in the roll_over image.
Now your car will race for two laps.
The graphics so far are OK but they could be much better. Are there any better graphics that we could use. Firstly consider the track.
Go back to the stage and then click on "backgrounds" and click on "edit"...
... click on "clear" to remove the original image ...
... then click on "import" ...
... then choose "Computer" ...
(Student common is drive I:)
... navigate to ICT / _year 7 / Topic 5 Scratch challenge / cars ...
... and select a track. Press "OK"
Press "OK" again and you hav a more professionally drawn looking track.
With my amateur graphics there was a clear green edge for the car to bump into but in this track the edge is white. So the script needs to be changed. Touching green needs to be touching white.
Next I can't have white as the colour of the edge and the colour of the finishing line so I will change the colour of the finishing line to yellow.
Fianlly the car needs to be improved to match the track.
Click back on the car and select "costumes" then click on "edit" ...
... click on "clear" ...
... click on "import" ...
... using the same folder as before (computer - drive I: - ICT / _year 7 / Topic 5 Scratch challenge / cars , select a car and press "OK" ...
... and finally press "OK" again.
Here is the car on the track.
Its in the wrong place. Can you see what I have changed? I have added a set position block at the start to put the car int he right position and a point in direction" block to point the car the rigth way on the track. I have also changed the script where the car returns to the start after a crash.
Now I have added two more blocks to make the car have the right costume when it restarts and it appears to need a push to get started.
... and then change the script so that the the car crashes the way it is suposed to; the costume changes to crash1 and then crash2.
Extension: add a second car and give the driver a chance to change the speed of their cars.