This directory contains example applications demonstrating various features of the Tomato Engine.
All examples use CMake for building:
# From the project root
mkdir build && cd build
cmake ..
cmake --build .
# Run examples (from build directory)
./bin/BasicExample # or BasicExample.exe on Windows
./bin/InputExample
./bin/PhysicsExampleDifficulty: Beginner
Topics: Initialization, Rendering, Main Loop
The simplest example showing how to:
- Initialize the engine
- Create a window
- Render a 3D object (spinning cube)
- Implement the main game loop
- Shut down cleanly
Perfect starting point for new users!
Difficulty: Beginner
Topics: Keyboard, Mouse, Gamepad, Camera Control
Demonstrates the input system:
- Keyboard input for movement
- Mouse clicks and dragging
- Mouse scroll for zooming
- Camera control and manipulation
- Cross-platform input handling
Learn how to make your game interactive!
Difficulty: Intermediate
Topics: Rigid Bodies, Collision, Physics Simulation
Shows physics simulation capabilities:
- Creating physics bodies
- Static vs dynamic objects
- Gravity and collision
- Spawning objects at runtime
- Physics-render synchronization
See realistic physics in action!
- Start with 01_basic to understand engine fundamentals
- Move to 02_input to learn user interaction
- Try 03_physics to add realistic simulation
All examples follow this pattern:
#include "tomato/tomato.hpp"
#include "tomato/globals.hpp"
using namespace tmt;
int main(int argc, const char** argv)
{
// 1. Initialize
var app = new engine::Application("Title", width, height, is2D);
// 2. Setup scene
// Create objects, cameras, etc.
// 3. Main loop
while (!glfwWindowShouldClose(renderer->window))
{
glfwPollEvents();
// Your game logic here
engine::update(); // Update all systems
}
// 4. Cleanup
engine::shutdown();
return 0;
}After trying these examples, you can:
- Combine concepts from multiple examples
- Check out real projects:
- Read the engine documentation in the main README
- Explore the engine source code in
include/tomato/
Build fails: Make sure all dependencies are properly installed (see main README)
Window doesn't open: Check graphics drivers are up to date
Physics acts weird: Ensure proper mass values (0 = static, >0 = dynamic)
Have an idea for a new example? Feel free to contribute! Good examples to add:
- Audio playback demo
- 2D rendering example
- Network multiplayer demo
- Particle effects showcase
- UI and ImGui integration