CacoEngine is a powerful 2D game engine built with modern C++ and SDL2, designed for rapid game development with robust physics simulation, flexible rendering, and intuitive object management.
- Hardware-Accelerated 2D Graphics: SDL2-powered rendering with multiple modes (points, wireframe, solid, textured)
- Physics Simulation: Rigid body dynamics with collision detection and response
- Flexible Object System: Hierarchical object management with mesh-based rendering
- Event-Driven Architecture: Complete input handling system for mouse and keyboard
- Cross-Platform: Support for Windows, macOS, and Linux
- Modern C++: Clean, maintainable code using C++17 features and smart pointers
- C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
- SDL2 development libraries
- CMake 3.10 or higher
- Clone the repository:
git clone https://github.com/yourusername/CacoEngine.git
cd CacoEngine
- Install SDL2 development libraries:
Ubuntu/Debian:
sudo apt-get install libsdl2-dev
macOS:
brew install sdl2
Windows: Download SDL2 development libraries from libsdl.org
- Build the project:
cmake -Bbuild
cd build
make
#include "engine.hpp"
#include "objects.hpp"
class MyGame : public CacoEngine::Engine {
public:
MyGame() : Engine("My Game", CacoEngine::Vector2Df(800, 600)) {}
void OnInitialize() override {
// Create a circle object
auto circle = std::make_shared<CacoEngine::Circle>(
CacoEngine::Vector2Df(400, 300), // Position
50, // Radius
CacoEngine::Colors[(int)CacoEngine::Color::Red] // Color
);
AddObject(circle);
}
void OnUpdate(double deltaTime) override {
// Game logic here
}
void OnKeyPress(SDL_KeyboardEvent& event) override {
// Handle keyboard input
}
void OnMouseClick(SDL_MouseButtonEvent& event) override {
// Handle mouse clicks
}
void OnMouseScroll(SDL_MouseWheelEvent& event) override {
// Handle mouse wheel
}
};
int main() {
MyGame game;
game.Run();
return 0;
}
CacoEngine follows a clean, modular architecture:
- Engine Core: Main game loop, event handling, and lifecycle management
- Object System: Hierarchical object management with built-in shapes and custom meshes
- Rendering System: Hardware-accelerated 2D rendering with multiple modes
- Physics System: Rigid body dynamics with collision detection
- Input System: Event-driven input handling for keyboard and mouse
- Asset Management: Texture loading and management system
- Triangle: Simple triangular shapes
- Rectangle: Rectangular objects with customizable dimensions
- Circle: Circular objects with radius control
- Sprite: Textured rectangular objects
- Mesh: Custom vertex-based objects
- RigidObject2D: Base class for physics-enabled objects
- RigidCircle: Physics-enabled circles with collision
- Box2D: Physics-enabled rectangles with collision
CacoEngine supports multiple rendering modes for each object:
- Points: Render only vertices as points
- WireFrame: Render object outlines
- SolidColor: Fill objects with solid colors
- Texture: Apply textures to objects
The physics system provides:
- Rigid Body Dynamics: Force-based movement with mass, velocity, and acceleration
- Collision Detection: Efficient collision detection between objects
- Collision Response: Customizable collision response callbacks
- Physics Integration: Automatic integration with the rendering system
Comprehensive documentation is available in the docs/
directory:
- Quick Start Guide - Get running in 5 minutes
- Engine Overview - Core concepts and design
- Architecture & Design - System architecture and patterns
- Objects & Rendering - Complete object system guide
The src/main.cpp
file contains a complete example application demonstrating:
- Basic engine setup and configuration
- Object creation and management
- Input handling and event processing
- Physics simulation and collision detection
Contributions are welcome! Please read the contributing guidelines and submit pull requests for any improvements.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built on top of the excellent SDL2 library
- Inspired by modern game engine architecture principles
- Thanks to the open-source community for feedback and contributions
If you encounter any issues or have questions:
- Check the documentation in the
docs/
directory - Review the example code in
src/main.cpp
- Open an issue on the GitHub repository
- Join our community discussions
CacoEngine - Simple, Powerful, Modern 2D Game Development
cmake -Bbuild;
cd build;
make;