How To Create a Racing Game in Scratch

MIT's free Scratch program can be used to create a basic racing game.The main goal of the game is to complete the track in a short period of time.

Step 1: You can open scratch.

You can find it in your computer's web browser.For beginners, scratch is a free programming resource.

Step 2: Click to create.

There is a tab at the top of the page.The Scratch interface can be opened by doing so.

Step 3: The sidebar has "All Tips".

There is a list of tips on the right side of the page.It will be easier to work in Scratch's interface if you do this.

Step 4: The title should be entered.

In the text box with "Untitled" written in it that's in the upper- left corner of the page, enter the title of your game.Clicking the prompt or logo will allow you to enable Adobe flash.

Step 5: There is a cat-shaped sprite.

You can click on the cat in the sprites window to get to the drop-down menu.Control can be held down on a Mac to prompt a drop-down menu.

Step 6: Click on the Backdrops tab.

It's at the top of the page.

Step 7: The background should be filled in.

Click the paint bucket icon to create the background on which the track is located.At the bottom of the page, you can choose your track's background color.The right side of the page has a background.

Step 8: You should draw your track.

Click the brush icon at the top of the list of tools to make your track uniform or irregular.At the bottom of the page, choose a color for your track.The brush width can be increased by dragging the sliders at the bottom of the page.The track should be drawn in a shape that is not necessarily circular.

Step 9: The finish/start line should be added.

Draw a line across the place in which you want the race to finish by decreasing the brush's width, and selecting a color that is different from the one you used for the background and track.This is where your car will start the race.The straight line tool has a back slash below it.

Step 10: Click the icon to paint it.

There is a brush-shaped line in the upper-right side of the "Sprites" pane.

Step 11: You can zoom in.

It looks like a magnifying glass icon with a in it, at least four times, if you click the "Zoom in" icon.There is a large icon in the middle of the right-hand pane.Clicking the icon in the sidebar's left-hand corner will close the "Tips" sidebar on the right side of the page if you didn't do it earlier.

Step 12: You can draw your racer.

You can use the brush to draw your racer.If you're making a car, you might want to use the rectangle tool to draw the body and then add the wheels with the circle tool.The center of your racer is represented by the icon.

Step 13: A racer is drawn.

Click the brush shaped icon below the "New costume" heading, then draw a crashed version of your racer.If your racer touches the grass or any other obstacles, this version will show.If your current racer is happy, you might make him a sad face.

Step 14: Choose your first racer.

Click the first one you drew to go to the next one.

Step 15: In front of the finish line, drag your racer.

You can do this in the left-hand pane.When you create your script, make sure that your racer is in the correct starting position.The racer will stop once it crosses the finish line, so make sure you are in front.

Step 16: You can click the script tab.

This is at the top of the page.

Step 17: Click on the event you want to see.

There is an option below the tab.There is a list of event-based code brackets.

Step 18: The "when flag clicked" event should be added to the pane.

Click and drag the "when [green flag] clicked" icon onto the right-hand pane, then release it there.

Step 19: Click to move.

The section has a blue link.

Step 20: You can add your racer's starting location.

When you start a new game, place your mouse over your racer.The racer's x and y coordinates can be found just above the upper-right side of the window.The "go to x: 16 y: 120" event should fit under the "when flag clicked" one.Click the "16" text box and type in the x value.You can type in the y value by pressing the Tab key.Press enter.

Step 21: The starting position should be changed.

The "point in direction 90" event can be found under the "go to x y" box.When the flag is clicked, this will ensure that your car is facing in the correct direction.

Step 22: You can tell which costume to use.

Click and drag "switch costume to costume2" to fit below the starting position.When you reset the game, your racer will reverting to its non-crashed costume.

Step 23: A movement script can be added.

Your racer will use this script to move forward.The "when flag clicked" event is separate from the first one.Click.The "forever" event is below the "when flag clicked" script.The "move 10 steps" option can be used to fit in the "forever" slot.Press Enter to change the "move 10 steps" variable.

Step 24: Controls can be created.

You can assign turning controls to your racer using the following script.There should be two separate events when space key is pressed.Click the "space" text box on one event and then click in the drop-down menu.Click the other "when space key is pressed" event's "space" box, then click in the drop-down menu.

Step 25: Motions should be added to the controls.

Click to use the arrow keys to turn your racer.The "turn 15 degrees" event is below the "right arrow" control.The "turn 15 degrees" event can be used below the "left arrow" control.

Step 26: An out-of-bounds rule is needed.

If your racer touches the background color, it will crash if you drag the "if then" option onto a blank space.Click and drag the "touching color" option into the blank space between "if then" and "then".Click the current color next to "touching color" and then click the background for your racer's track.To fit in the "if then" gap, drag "switch costume to" after clicking.To fit in the "forever" gap, drag the entire assembly.Drag the "stop all" option to fit below the costume option.Click "all", then click in the drop-down menu.

Step 27: You should make a finish line reaction.

When your racer crosses the finish line, the following script will create a victory message: Click, then drag the "if then" option onto a blank space.Click and drag the "touching color" option into the blank space between "if" and "then".Click the current color next to "touching color", then click the finish line.The "say hello for 2 secs" option should fit inside the "if then" gap.Change "hello" to "You won!"You can change the "2" to whatever amount of time you want.The "if then" assembly should be dragged into the "forever" brackets.

Step 28: Take a test of your game.

Click the icon in the bottom-right side of the backdrop area and then use the arrow keys to move around your track.You should be able to get to the finish line.If you determine that the track is too narrow or irregular to complete, you can adjust it by clicking on the icon in the lower- left side of the page, clicking the tab, and drawing in areas which need fixing with your track's primary color.