Welcome to the third and final part of our Car Race Game in Scratch.
Click the Green Flag to start and drive counter clockwise around the track.
Use the Up Arrow to accelerate forwards, and the Down arrow to reverse.
Use the Left and Right Arrows for steering, and Space Bar for brakes.
(The faster you go the tighter the steering, so be careful not to oversteer at higher speeds).
If you hit the grass, the car slows down dramatically.
The car has a limiter that slows it back down if maximum speed is exceeded.
Watch out for oil hazards on the USA Track!
The car is hard to steer once the speed gets up, and stays at a constant speed until you either brake or hit the grass. Concentrate mainly on steering with the left arrow key, and only tap the up key to go faster as you get better on each lap.
It is best to drive the car towards the middle or the outside of the track. Keep practicing until you achieve mastery. You can change the Car script to different number values if you don't like the game as it currently is.
The Car Race game is based on a game by "Spark98" called "Awesome Car Race" which we downloaded from the MIT Scratch site.
In the Part 3 build we add the following features to the Car Race Game:
- Random Oil Slicks that spin the car around on the track
- Display a Best Lap Time Value
- Race only lasts for 10 laps
- A "Game Over" Message
The Part 2 game has an Introduction screen with a menu of three Race tracks that can be selected.
The Part 2 tutorial can be accessed by clicking the following link:
The Part 1 tutorial can be accessed by clicking the following link:
The following YouTube video explains in detail how to build Part 3 of the Passy World Car Race Game.
Note that by adjusting the bottom right hand controls, it can be viewed full screen in HD. (Press Escape to return to this blog page when finished).
In Part 3, the first thing we needed to do was create a 40x40pixel Oil Slick hazard to use on our track. This sprite was built using Adobe Fireworks and its Bezier Curves Pen Tool.
Here is the Oil sprite if you would like to use it in your project. click on it, and then save these to your PC using your web browser.
The next thing was to import the Oil sprite into Scratch, and then create the Script for the Oil Slick sprite, so that it could appear every now and then on the USA track at various locations.
We then needed to add code to the Car Sprite, so that it could check if it was touching the Brown colour of the oil slick, and then go into a Spin momentarily.
Note in the script below, the "touching colour is actually dark brown, not black. Get a perfect match by using the scratch eye dropper selector and dip into an oil slick sprite on the track.
We have also modified the script to be slightly different to the one shown in the YouTUbe "How To" video.
The next thing we did was add a 10 Lap Limit to the race, and a Game Over Message.
In the Car Script we already had the lap counter variable being used, so all we had to do was Broadcast out a "Game Over" message, when the Laps reached 10 completed.
The next step was to create the "Game Over" by using the Scrath Paint Sprite editor and putting in the "Game Over" text message using "Earwig Factory" font at a size of 60.
We then added the following Script blocks onto the "Game Over" sprite.
The final item to add was the display of the Best Lap Time.
We needed to do this on the Car sprite, and add two new variables: "Best" and "Prev Best". The Car sprite code was then modified to contain the following additional new code.
So that's the Car Race Time Trial Game completed.
We did try to add some sound effects but were unable to find or make decent enough car engine sounds that would loop okay in Scratch.
Make sure you give our tutorials a go, by downloading and installing the Scratch Development Envioronment for free on your PC from the following link:
You'll definitely have some fun Racing Cars with Scratch.
Big Passy Wasabi