Physics game in C++

Hill Climb Racing

A side-scrolling driving game with physics, written from scratch in C++ on SDL2. Custom collision detection and an optimized game loop, with no game engine.

Stack
  • C++
  • SDL2

Fig. 1 · A vehicle on generated hills

Original sketch

or focus the canvas and use ← →
Original sketch. Made for this site in the spirit of the project, with wheel and terrain contact checks, slope forces and a fixed-step loop. It isn’t footage from the game.

What I built

A physics-based driving game written from scratch in C++ on SDL2, without a game engine. It started as a course lab project.

  • Custom collision detection between the car and the terrain.
  • Game-loop optimization to keep the simulation and rendering smooth.

Why it’s here

It’s the most playful project on this site, but it still had real problems to solve: stepping the motion forward frame by frame, detecting contact with uneven ground, and fitting all of it into each frame’s time budget.

About the toy above

The terrain toy is original artwork made for this site, not a screenshot of the game. It’s a small physics sketch in the same spirit: a car on randomly generated hills.

Site index