Skip to content

About

C++4 teaching materials for discrete and continuous 2D collision detection with C++ and Raylib

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Collision Detection in Game Design

Teaching material for C++4 in Game Design, covering discrete and continuous 2D collision detection through interactive Raylib visualizers and two practical workshops.

  • Author: Eliel Camargo-Molina
  • Course: C++4 in Game Design
  • Original course edition: September–October 2025
  • Repository edition: 1.0.0

What is included

Order Module Main ideas Student activity
1 Discrete collision lecture MTVs, circles, AABBs, OBBs, convexity, SAT Explore five interactive visualizations
2 Breakout SAT workshop Circle–convex SAT and collision response Implement one SAT narrow-phase function
3 Continuous collision lecture TOI, slabs, quadratics, relative motion, Minkowski sums, swept AABBs Explore six CCD visualizations
4 Plinko CCD workshop Broad phase, narrow phase, earliest collision Assemble a CCD collision pipeline

The repository includes both starter and solution executables for each workshop. See TEACHING_GUIDE.md for suggested delivery.

Prerequisites

  • A C++17 compiler
  • CMake 3.20 or newer
  • Git and an internet connection during the first configuration

Raylib 5.5 is downloaded automatically by CMake. No global Raylib installation is required.

Build everything

cmake -S . -B build
cmake --build build --parallel

Executables are placed in build/bin (build/bin/Debug with some multi-configuration generators):

  • lecture1_visualizer
  • breakout_starter
  • breakout_solution
  • lecture2_visualizer
  • plinko_starter
  • plinko_solution

To build only one target:

cmake --build build --target breakout_starter

Workshop workflow

The starter targets deliberately compile with incomplete student functions:

  • Breakout: implement CirclePoly_SAT_MTV in workshops/01-breakout-sat/collision_engine.cpp.
  • Plinko: implement FindEarliestCollision in workshops/02-plinko-ccd/workshop.cpp.

Completed versions are kept in separate *_solution.cpp files. They are not needed by the starter targets.

Shared conventions

  • Touching counts as a collision.
  • Collision normals point from the first object (A) toward the second (B).
  • To move A out of B, use -normal * depth.
  • CCD times are normalized to the current frame: t is in [0, 1].
  • All polygon SAT examples assume convex polygons.

Scope and limitations

These are teaching examples, not a production physics engine:

  • Breakout uses discrete collision detection and can tunnel at extreme speeds.
  • The examples resolve one selected contact at a time rather than constructing a full contact manifold.
  • Plinko stops at the first impact in a frame and does not consume the remaining frame time after the bounce.
  • The broad phase in Plinko scans all pegs; the swept bounds reduce expensive narrow-phase tests but are not a spatial acceleration structure.

Attribution, citation, and licenses

The teaching material was created by Eliel Camargo-Molina for C++4 in Game Design. See ATTRIBUTION.md for third-party notices and CITATION.cff for citation metadata.

See LICENSE.md for the file-by-file license mapping.

About

C++4 teaching materials for discrete and continuous 2D collision detection with C++ and Raylib

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages