Skip to content

JoeKL/bouncy_ball

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bouncy Ball (Speedrun)

Language Library Status

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).

🎮 How it Works

The simulation runs on a simple physics loop:

  1. Integration: Updates position based on velocity (vel_x, vel_y).
  2. Gravity: Applies constant downward acceleration.
  3. Collision Detection: Checks against window boundaries.
  4. Response: Reflects velocity and applies a DAMPENING_FACTOR (0.95) to simulate energy loss (friction/restitution).
  5. Rendering: Manually calculates circle geometry ($x^2 + y^2 < r^2$) and writes directly to the pixel buffer.

✨ Features

  • 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.

🚀 Usage

Prerequisites

  • Rust & Cargo

Run the Simulation

cargo run --release

About

A minimalist 2D physics simulation written in Rust under 1 hour. Features a bouncing ball with gravity, collision detection, velocity dampening, and dynamic color changes using a raw pixel buffer.

Resources

Stars

Watchers

Forks

Contributors

Languages