Sort of Car race Game

This guide has been designed to help you create a simple game. Follow these step-by-step instructions to create an interesting set of effects.

Use the left and right keys to keep your car on the track.

Stage 1 - Making the track

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. You are drawing a bird's eye view of a track. make sure that you have zoomed out as far as you can go otherwise you will have a very small track. As a guide the track should be "two brushes" wide.

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.

1. Screenshot your project so far and describe how you made the track.


Stage 2 - Making the 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. Use the chequerboard background to help you to get straight lines.

Using a series of rectangles and lines draw a racing car shape, something like this. This is a plan view of a car, a car seen from above so the wheels will be rectangles not circles. Make sure that the colour of the car is different from the colour of the black tyres. The circle in the centre is the driver's crash helmet.

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 suitably sized car on the track. Notice I have deleted the other cat costume from the car.

Rename the car sprite from "sprite1" to "car".

8. Screenshot your project so far and describe how you made the car.


Stage 3 - Making the car move

Click back on the car and then "scripts".

Add a script like this 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 "left arrow" ...

... add the motion block "turn 15" to make the car turn left.

Repeat this for turning right (using the right arrow).

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.

8. Screenshot your project so far and describe how you made the car move.


Stage 4 - Keeping the car on the track

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. Now it is possible to play the game at a simple level.

8. Screenshot your project so far and describe how you made the car stay on the track.


Stage 5 - Making improvements

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 costumes to show the car in flames.

Click on the car and then "costumes".

This is important, click on "copy" to make a copy of the car. This is to make sure that the original car is untouched.

Now edit the car to add some flame to it.

I have added another burning car image so I can animate between the two so it appears that the car is burning. Adding more costumes and making the drawn changes betwen costumes more gradual will improve the quality of your game in the end.

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.

Screenshot your project so far and describe ading flames to the car sprite.

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?

8. Screenshot your project so far and describe how you made the car burst into flames when it crashes.


Stage 6 - Winning a one lap 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 the 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 the car crosses the white line; touching the colour white.

Try it and see if it works; it does.

8. Screenshot your project so far and describe the car wins a one lap race.


Stage 7 - Winning a Two lap race

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.

Screenshot your project so far and describe how you have added code to see if the car has driven round the track twice.

8. Screenshot your project so far and describe how the car wins a two lap race.


Stage 8 - Better graphics

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 share is drive P:)

... navigate to / Department / Computing / _2017-2018 / KS3 / Year 8 / Cars ...

... and select a track. Press "OK"

Press "OK" again and you hav a more professionally drawn looking track.

Can you spot the main issue with the 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.

The script for the car needs to change as well as demonstrated in the roll_over shown below..

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 P: (student share)) then navigate to / Department / Computing / _2017-2018 / KS3 / Year 8 / Cars ... , select a car and press "OK" ...

... and finally press "OK" again.

Here is the car on the track.

Screenshot your project so far and describe changing the background and the car sprite to images stored on the student drive.

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.

Next copy and edit the costumes of the car so that there are flames for the cartoon car if or when it crashes. Delete the old costumes that are no longer needed.

Finally rename the costumes to be crash1 and crash 2...

... 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.

Project done.

8. Screenshot your project so far and describe how you changed the graphics.


Stage 9 - Extension

Add a second car and give the driver a chance to change the speed of their cars. Hint you will need to use a variable so look at the binary game to see how this is done.

9. Screenshot your project so far and describe how you made the two player game.


Year 8 Extension

When you add a second car and give the driver a chance to change the speed of their cars, you really should give the drive a chance to brake. Hint you will need to use a variable so look at the binary game to see how this is done.

9. Screenshot your project so far and describe how you improved the two player game.


Recent Posts

May 24

Repairing a hyperspace window

You may have noticed the time shift in the Blue coridor, there is a redshift at certain times of the day; this has caused the bells to malfunction and the PCs are runing slow as the server room is also moving ever so slowly into the 5th dimension. The Lightspeed engineers are working hard to fix the hyperspace window being generated by the tidal effects of big data and the weaknesses in the walls caused by excessive data mining. Cambridge Analytica's data scraping has also contributred to the weakness in the space time continuum. There is no need to be afraid as everything is should be resolved in the near future; nevertheless steps are being taken, mostly from the gold staircase.

Any further information will be included here when and if we get it.

July 18

Adventuring with A GDPR SUrveyor

The GDPR surveyors will be in the College in the near future checking that you understand your obligations under GDPR. Are you aware of the consequences? Do you know who knows about you? Do you know what the people you don't know about, know about you? Have you checked your own settings? Are you privacy minded? The GDPR surveyors will check. They know you, possibly better than you do but maybe not as well as the Internet knows you.

July 14

Games for Free

There are a number of games that you can get for free that are really good. They are really good at collecting all of your data and passing it on to someone else. You don't know who they are and you don't know why they are collecting your data. They have your data and access to your friends. In minutes they have your friends' data and are collecting the data from their friends. If its a good game you will even tell your friends about it so you do their sneakiness for them and still tell your friends. It will never happen to you but hey that game...


Neural Implants

The pros and cons. Mostly cons.

Be permanently connected to Google and you can ask Alexa in your head; only you can hear the answer...