A physics simulation "speedrun" project built in under an hour. The goal was to implement a fully functional bouncing ball with gravity, dampening, and user interaction using only a raw pixel buffer (minifb).
The simulation runs on a simple physics loop:
-
Integration: Updates position based on velocity (
vel_x,vel_y). - Gravity: Applies constant downward acceleration.
- Collision Detection: Checks against window boundaries.
-
Response: Reflects velocity and applies a
DAMPENING_FACTOR(0.95) to simulate energy loss (friction/restitution). -
Rendering: Manually calculates circle geometry (
$x^2 + y^2 < r^2$ ) and writes directly to the pixel buffer.
- Physics Engine: Custom implementation of 2D kinematics and elastic collisions.
- Software Rendering: Draws the circle pixel-by-pixel without a GPU API.
- Interactive Controls: Use Arrow Keys to add force to the ball.
- Dynamic Visuals: Ball changes color on every bounce.
- Rust & Cargo
cargo run --release