Sunday, May 8, 2011

Scratch Car Race Game - Part 1


Welcome to Part 1 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 over-steer 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.

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.

Our Car Race game is based on a game by "Spark98" called "Awesome Car Race" which we downloaded from the MIT Scratch site.

We obtained the Red Car from a YoYo Games forum on the internet, saved it, then cut it out of the Sprite sheet and resized it using Adobe Fireworks to around 50 pixels by 50 pixels. Note that it then needs to be further resized in Scratch, to make it a suitable size for the race track.

Red Car Sprite

Here is the Finish Line which we made using Adobe Fireworks with a Hard Line square paint brush tip.

Finish Line

The following YouTube video explains in detail how to build the Passy World Car Race Game using Scratch.

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



Here are the completed Script codes for the Car.

(Make sure in Scratch that the Rotation Arrow is enabled next to the image of the Car at the top of the Script, which is not shown here).

Car Script Code

Here are the Variables that need to be set up for this Game.

Variables

Ticks next to the Variables are made by clicking the mouse there.
These ticks make the current value of the variables appear on the screen. Note that we can move them around the screen to where we want them using the mouse, while we are building the game.

Here is the Script for the Skid maker when the car exceeds its maximum speed.

Skid Script Code

Here is the Finish Line Sprite Script.

Finish Line Code

Here is the Stage Script.

Stage Code

The following 480x360 JPG image is for our Race track if you would like to use it in your game.

Track 1 Stage

The track was built in Adobe Fireworks using "Bezier Curves" and some geometric shapes.
If you would like to learn more about Bezier Curves, then click the link below.

http://passyworldofict.blogspot.com/2010/06/fireworks-bezier-curves.html

So that's Part 1 of our Scratch Car Racing Game.

In future extensions we are hoping to build in the following enhancements:
  • Multiple Tracks to Choose From
  • An Opening Screen (where they can choose a Track)
  • A Damage variable for when they hit grass
  • Random Oil Slicks that spin the car off the track
  • Race only lasts for 10 laps
  • Sound Effects
  • Display a Best Lap Time Value
  • A "Game Over" Message
Click the following link to go to Part 2 of our Car Race Tutorial where we add an opening Menu and extra tracks to race:

http://passyworldofict.blogspot.com/2011/05/scratch-car-race-game-part-2.html

Make sure you give our tutorials a go, by downloading and installing the Scratch Development Environment for free on your PC from the following link:

http://info.scratch.mit.edu/Scratch_1.4_Download

You'll definitely have some fun Racing Cars with Scratch.

Enjoy,
Big Passy Wasabi

No comments:

Post a Comment