AgentGames

Search titles, descriptions, models and tags. Press Enter to see results.

🏁 Guide

How to make a racing game with AI

A racing game is one car, three numbers and a lap counter. Get the three numbers right and even a rectangle on a grey track feels good to drive.

Updated 5 October 2026 5 min read By the Agent Games team
Jump to a section
  1. Four steps to a car you want to drive
  2. The three numbers behind how a car feels
  3. Why your lap times are wrong on another machine
  4. Laps, checkpoints and cutting the track
  5. Common questions
  6. Where to go next

Ask for a top down racer in one file: one car, one track, three laps, and a best time kept between sessions. Then spend your time on how the car turns, because that is the entire game. Three dimensions can wait, and usually should.

Why top down and not 3D

A 3D racer needs a track mesh, a camera, collision against the scenery and a car that does not sink through the road. A top down racer needs a car and a mask of where the road is. The driving feels identical to tune, and one of them exists tonight.

Four steps to a car you want to drive#

Paste the prompt below and open what it writes

Claude, ChatGPT and Gemini all handle this one well. It is a small amount of maths and a lot of tuning.

Drive one lap without looking at the timer

The question is not whether it works. It is whether turning feels like driving or like dragging a mouse pointer.

Change exactly one of the three numbers

Grip, turn rate, acceleration. Change one, drive a lap, decide. Changing two tells you nothing about either.

Only then build the track

Corners, a second lane, a wall, a rival car. All of it is wasted on a car that is unpleasant to steer.

PromptCopy this, paste it, send it
Build a top down racing game as ONE self-contained .html file. No
frameworks, no images, no 3D.

TRACK: a closed loop seen from above, drawn with canvas shapes. Grass
outside, tarmac inside. Driving on grass halves the top speed. The view
scrolls to follow the car and the car stays near the centre.

CAR: a rectangle with a nose. Up accelerates, down brakes and reverses,
left and right steer. Steering only turns the car while it is moving.

HANDLING: keep velocity as a vector. Each frame, split it into the part
pointing along the car and the part pointing sideways, and bleed the
sideways part away according to a GRIP value. Low grip should slide.

LAPS: four checkpoints around the loop. A lap only counts when all four
have been crossed IN ORDER, so cutting the track does not score. Three
laps to finish. Show current lap time, last lap and best lap.

SAVING: best lap goes in localStorage and survives a reload.

PHONE: tapping the left or right half of the screen steers, and the car
accelerates by itself.

Base everything on seconds elapsed between frames, capped at 0.05. Put
GRIP, TURN_RATE, ACCELERATION, BRAKE and MAX_SPEED in one CONFIG object
at the top with a comment on each.

The handling paragraph is the whole game. Without it you get a car that pivots on the spot like a tank, which is the single most common thing a first racing build gets wrong.

The three numbers behind how a car feels#

Every complaint about a first racing build comes back to one of three values, and the fastest way to learn which is to push each one to an extreme on purpose.

Three numbers decide whether driving feels right Nearly every complaint about a first racing build comes back to one of these. Grip How fast sideways speed bleeds away Too high and it drives on rails. Too low and it skates. Say: the back should step out under power. Turn rate Degrees per second at full lock Too high and it spins. Too low and corners feel like work. Say: it turns too sharply at walking pace. Acceleration How quickly it reaches top speed Too high and the track is too short. Too low and it is dull. Say: it takes too long to get going. Tune them one at a time. Changing two and driving once tells you nothing about either.
Set grip to almost nothing for one lap, then to almost total. You will understand the number better in two minutes than in any amount of reading.
It feels likeThe numberAsk for
A tank pivoting on the spotTurn rate is applied while stoppedSteering scaled by current speed
Driving on rails, no weightGrip is too highLess grip, so the back steps out under power
Skating on ice, no controlGrip is too lowMore grip, and slightly slower steering
Floaty, slow to respondAcceleration is too lowFaster acceleration and a lower top speed
Over before the first cornerTop speed is too high for the trackA longer track, or a lower top speed

Describe the feeling, not the value. The model can see the whole config, and you can feel the car.

Why your lap times are wrong on another machine#

Racing is the genre where frame rate dependence stops being invisible. A car moved by a fixed amount per frame is twice as fast on a 120Hz screen. A best lap set on a gaming laptop is then unbeatable on a phone, and the leaderboard means nothing.

Why the same game is twice as fast on a 120Hz screen Frames arrive whenever the browser is ready a slow frame Counting frames x += 3 moves three pixels per frame, so the player is twice as fast on a 120Hz laptop as on a 60Hz one, and crawls whenever a frame runs long. Counting seconds x += 180 * dt moves 180 pixels per second on every machine, because dt is how long the last frame actually took. The part that is still missing Alt-tab for a minute and dt is 60. The player teleports through every wall. dt = Math.min((now - last) / 1000, 0.05) caps the damage at one twentieth of a second.
Movement per second, not movement per frame. In most games this is a polish item. In a racing game with saved lap times it is the difference between a record and a measurement of somebody's monitor.

The cap matters as much as the delta. Without one, a tab left in the background returns with a gap of several seconds, and the car teleports through the wall it was about to hit. Capping the step at 0.05 seconds keeps the worst case to one frame of overshoot.

Laps, checkpoints and cutting the track#

A lap counted by crossing the start line is a lap counted wrong. The player reverses over the line three times and finishes the race without driving. On a track with a hairpin they can cut a third of it and still score.

  • Four checkpoints, crossed in order. Keep an index of the next expected one. Crossing any other does nothing. The lap counts only when the player returns to the first.
  • Make them wide. A checkpoint should span the whole width of the road and a little beyond. A player who clips the grass on a corner should not have the lap silently voided.
  • Show the next one while testing. Ask for a debug key that draws the checkpoints. Half an hour of confusion ends the moment you can see them.
  • Time the lap from the crossing, not the key press. Otherwise the first lap includes the moment you spent working out which key accelerates.

🏁Racing games written by AI

Common questions#

Can AI make a racing game?

Yes. A top down racer with laps, lap times and a saved best is one prompt and a browser. The work is not the code. It is tuning the three numbers that decide how the car turns, which is the same job in any racing game ever made.

Why does my car spin on the spot like a tank?

Steering is being applied regardless of speed. Ask for the turn rate to be scaled by how fast the car is actually moving, so a stationary car cannot rotate. This single change is the difference between a vehicle and a cursor.

How do I make the car drift?

Keep velocity as a vector, split it each frame into the part along the car and the part sideways, and bleed the sideways part away slowly. A high bleed is grip and a low bleed is a slide. Drifting is that one number, not a separate feature.

Should I build a 3D racing game instead?

Not first. A 3D racer adds a camera, a track mesh and collision against scenery, and none of that improves how the car feels. Build the handling top down, then rebuild the view in 3D if you still want to.

How do I stop players cutting the track?

Place four checkpoints around the loop and require them to be crossed in order before a lap counts. A lap counted by the start line alone can be scored by reversing over it, which is the first thing anybody tries.

How do I add a computer controlled opponent?

Give it the same car and a list of points around the track to steer towards, with a small random offset so it does not drive a perfect line. Do this after the player's car feels right, because a rival inherits whatever is wrong with the handling.

Where to go next#

When you have caught yourself driving one more lap, publish it. It gets a page recording the model, the prompt and the tokens behind it, and a leaderboard other people can take your best lap off you on.

The general method is in how to make a game with AI. If you do want the 3D version later, the 3D guide covers the camera and the scene. Prompts for common faults are in the prompt guide, and the racing games here are worth a few laps first.