o
odin.langpkg.dev
packages / library / pong-odin

pong-odin

353017elibrary

No description provided.

No license · updated 5 months ago

Pong

A clean, minimal two-player pong game built in Odin with monochrome aesthetics.

Build & Run

make build    # Compile optimized binary
make run      # Build and execute
make dev      # Build with debug symbols and run
make clean    # Remove build artifacts

Controls

Player 1 (Left Paddle)

  • W: Move up
  • S: Move down

Player 2 (Right Paddle)

  • ↑: Move up
  • ↓: Move down

Game

  • Space: Start game / Start round / Continue after round end
  • ESC: Pause/Resume (during gameplay) or Exit game

Rules

Best of 3 rounds. First player to win 2 rounds wins the match.

Game States

  • Menu: Initial screen, press Space to start
  • Round Active: Gameplay in progress
  • Paused: Game frozen, press ESC to resume
  • Round End: Between rounds, press Space to continue
  • Match End: Game over, press Space to return to menu

Architecture

src/
├── main.odin      Entry point & game loop
├── game.odin      State machine with enter/exit callbacks
├── systems.odin   Input, physics, scoring, and render systems
├── entities.odin  Data structures and state handlers
├── physics.odin   Movement & collision detection
├── input.odin     Input abstraction with debouncing
├── render.odin    Rendering functions
├── theme.odin     Theme definitions
└── config.odin    Constants

Architectural Features

  • Systems Architecture: Separated concerns into input, physics, scoring, and render systems
  • State Machine with Callbacks: Each state has on_enter, on_update, and on_exit handlers
  • Input Debouncing: Prevents double-trigger issues with configurable delay
  • Player Abstraction: Player struct contains paddle, score, and input configuration
  • No Global State: All state contained in Game struct for testability
  • Clean Separation: Data, logic, and presentation fully separated