Skip to content
ExploreMapGamesStoriesComicsVideosStudioPrintablesCode LabJourneys
By age โ–พ
  • ๐Ÿงธ Tiny Explorers2โ€“5
  • ๐Ÿฆ‰ Curious Learners6โ€“8
  • ๐Ÿ”ญ Young Investigators9โ€“12
  • ๐Ÿš€ Trailblazers13โ€“17
๐Ÿ‘คParent sign in
Kids Amazing World

A creative learning playground. No ads, no tracking, no chat. Every item is reviewed before it appears.

Explore

  • Explore
  • Learning journeys
  • Surprise me
  • Parent planner

For grown-ups

  • Child safety
  • Privacy
  • Terms (draft)
  • Free & Premium
  • Parent sign in

About this content

Some items in this build are placeholders written for development. Third-party resources are only listed with permission, a license, or an official embed.

โ† All game tutorials

๐ŸŽ๏ธ Racing

Dodge the traffic and grab the boosts.

How to playYour functionsSettings you can changeStep by stepIdeas to tryLessons

๐ŸŽฎ How to play

Reach the goal score before you run out of lives. You score for every rival you pass, and boosts give bonuses. Crashing costs lives.

  • โ—€ โ–ถ buttons or โ† โ†’: Steer into the next lane.

โš™๏ธ Your functions

You write these functions. The game calls them when something happens.

  • onPass()

    Runs every time a rival car goes past you safely.

    function onPass() {
      score = score + 1;
    }
  • onCrash()

    Runs when you hit a rival.

    function onCrash() {
      lives = lives - 1;
    }
  • onPickup()

    Runs when you drive over a boost.

    function onPickup() {
      score = score + 5;
    }
  • onTick()

    Runs at every moment of the race. Use it to change things as you drive.

    function onTick() {
      // try changing speed here
    }

๐ŸŽš๏ธ Settings you can change

Variables at the top of your code are the game's settings. Change a value, press Play, and see what happens.

car = "๐ŸŽ๏ธ"
Your car.
rival = "๐Ÿš—"
The other cars.
boost = "๐Ÿ’Ž"
The pickups.
goal = 50
Reach this score to win.
lives = 3
Crashes you are allowed.
speed = 2
From 1 (slow) to 5 (fast).
traffic = 3
From 0 (an empty road) to 5 (very busy).
distance = 0
How far you have driven. The game counts it up for you. set by the game
score = 0
Your points. The game starts it at 0 and you change it in your functions. set by the game

๐Ÿชœ Step by step

Each step shows code you can add to the end of your game's code. A function or variable written later replaces the earlier one, so you never have to delete anything.

  1. 1Play the starter

    Steer between the cars. Passing a rival runs onPass, crashing runs onCrash, and a boost runs onPickup.

    function onPass() {
      score = score + 1;
    }
  2. 2A busier road

    More traffic means more to dodge.

    let traffic = 5;
  3. 3Use onTick and distance

    onTick runs every moment, and distance counts up as you drive. You can make something happen at a certain distance. Here the race jumps to speed 4 at distance 50.

    function onTick() {
      if (distance === 50) {
        speed = 4;
      }
    }
  4. 4Nitro boosts

    A boost makes you faster, and a crash puts you back to slow. Changing speed in the functions makes the race feel alive.

    function onPickup() {
      score = score + 5;
      speed = Math.min(5, speed + 1);
    }
    
    function onCrash() {
      lives = lives - 1;
      speed = 1;
    }
Show the full starter code
// ๐ŸŽ๏ธ Racing!
let car = "๐ŸŽ๏ธ";
let rival = "๐Ÿš—";
let boost = "๐Ÿ’Ž";
let goal = 50;          // reach this score to win
let lives = 3;
let speed = 2;         // 1 (slow) to 5 (fast)
let traffic = 3;       // 0 (empty road) to 5 (very busy)
// The game keeps a variable called distance: how far you have driven.

function onPass() {
  score = score + 1;
}

function onCrash() {
  lives = lives - 1;
}

function onPickup() {
  score = score + 5;
}

// runs every moment of the race
function onTick() {
  // try changing speed here
}

๐Ÿ’ก Ideas to try

  • A police chase: a ๐Ÿš“ car and a goal of 100.
  • An empty road with lots of boosts and a very high speed.
  • Speed up the race only while you are on a streak of passed cars.

Tips

  • You can only change lane one step at a time, so look ahead!
  • If the race feels too easy, try a traffic of 5.

๐ŸŽ“ Lessons for this game

  • ๐Ÿ”’Racing: start your enginesPremium
  • ๐Ÿ”’Racing: speed rampPremium
  • ๐Ÿ”’Racing: boosts and crashesPremium

๐Ÿ› ๏ธ Make your own Racing game

Game Studio and the full lessons are part of Premium.

See Premium
โ† ๐Ÿ„ Platformer๐Ÿš€ Space Battle โ†’