A single-tower defense game created with the Odin programming language, using Box2D for physics and Raylib for graphics.
This tower defense game features a single tower that must defend against waves of enemies approaching from all sides. The game demonstrates the integration between Box2D physics and Raylib rendering.
- Single tower with attack capabilities
- Multiple enemy types with different characteristics
- Physics-based movement and collisions using Box2D
- Real-time rendering with Raylib
- Score tracking and wave progression
- Debug mode to visualize physics bodies
- The tower automatically targets and fires at the closest enemy
- Enemies spawn from the edges of the screen and move toward the tower
- When enemies reach the tower, they damage it and reduce player lives
- The game ends when all lives are lost
- Waves become progressively more difficult with faster spawn rates and tougher enemies
- Enter: Start game from menu / Restart after game over
- F1: Toggle debug mode (shows physics bodies and debug information)
- ESC: Exit game
This game serves as a demonstration of how Raylib can render Box2D physics objects. The integration works as follows:
-
Physics System (Box2D)
- Handles all collision detection and resolution
- Manages object movement and forces
- Maintains the physical state of all game entities
-
Rendering System (Raylib)
- Translates physical positions to screen coordinates
- Renders game objects based on their physical properties
- Provides visual feedback for game state
-
Coordinate Conversion
- Box2D uses a meter-based coordinate system
- Raylib uses a pixel-based coordinate system
- The
PHYSICS_SCALEconstant (30 pixels per meter) handles the conversion
src/: Contains all source code filesmain.odin: Entry point of the applicationgame/game.odin: Game logic and mechanicsphysics/physics.odin: Box2D physics integrationrenderer/renderer.odin: Raylib rendering of Box2D objects
- macOS operating system
- Odin programming language
- LLVM
- Xcode Command Line Tools
This project is provided as-is for educational purposes.
- The Odin programming language team
- Raylib developers
- Box2D physics engine