English | ็ฎไฝไธญๆ
A 2D sandbox game engine developed with modern C++17, featuring bgfx rendering backend, terrain editing, fluid simulation, ECS architecture, and more.
- Cross-platform rendering with bgfx - Supports DX11/OpenGL/Metal/Vulkan backends
- Multi-view rendering architecture - Layered rendering (solid, alpha, UI layers)
- 2D tile map rendering - Efficient batch rendering
- Particle system - Supports explosions, debris, and other visual effects
- Day-night cycle - Dynamic lighting and sky color changes
- Terrain editing - Real-time digging, filling, and blasting
- Fluid simulation - Advanced water flow simulation system (CA algorithm)
- Physics system - AABB collision detection, gravity simulation
- Character control - Platformer mechanics, multi-character switching
- Procedural generation - Random terrain generation (Perlin noise)
- ECS architecture - Entity-Component-System based on EnTT
- Scene management - Scene stack support (push/pop/replace)
- Event system - Dual-layer event bus (OS layer + gameplay layer)
- Resource management - Async resource loading, smart pointer management
- UI system - Custom UI framework with layout, events, and animations
- UINode - Base UI node class (transform, hierarchy, visibility)
- UIButton - Button component (hover, click, disabled states)
- UIPanel - Panel container (background, border, rounded corners)
- UIToolbar - Toolbar (multi-slot, icons, selection state)
- UIDialog - Dialog system (centering, overlay)
- UICharacterPanel - Character info panel (health bar, name, control button)
- TextRenderer - Text renderer (TrueType fonts, alignment, colors)
- Auto layout management - Responsive window resizing
- Event handling - Mouse hover, click, scroll wheel
- RAII rendering scope - Automatic render state management
- Color themes - Predefined color constants
- DPI scaling - High-resolution display support
-
MenuScene - Main menu scene
- Start game, settings, exit buttons
- Background rendering, title display
-
WorldSelectScene - World selection scene
- World list (3 preset worlds)
- Create new world dialog
- Seed input, world name editing
-
GameScene - Main game scene
- Terrain rendering (solid/water)
- Character system (player + 3 NPCs)
- Toolbar (8 tool slots)
- Character info panel
- Day-night cycle
-
PauseScene - Pause menu
- Continue, settings, return to main menu
- Semi-transparent overlay
-
SettingsScene - Settings scene
- Sound/music volume adjustment
- Fullscreen toggle
- Day-night time adjustment
- SDL_mixer based - Supports MP3/WAV/OGG
- Audio management - Fade in/out, volume control
- Group management - Independent control for sound effects and music
- Async loading - Lazy resource loading
- InputSystem - Unified input management
- Keyboard input - Keyboard state queries, key events
- Mouse input - Coordinate conversion, button states, scroll wheel
- Window events - Window resize, maximize, close
Tina/
โโโ src/
โ โโโ core/ # Core systems (logging, time, memory)
โ โโโ engine/ # Engine core (application, scenes, events, input)
โ โโโ renderer/ # Rendering system (shaders, textures, tile rendering)
โ โโโ ui/ # UI system (components, renderers, layout)
โ โโโ ecs/ # ECS system (components, systems)
โ โโโ game/ # Game logic (scenes, maps, characters)
โโโ resources/ # Resource files (shaders, textures, audio, fonts)
โโโ image/ # Game screenshots
โโโ docs/ # Documentation
Main Menu
- Click "Start Game" to enter world selection
- Click "Settings" to adjust volume and display options
- Click "Exit" to close the game
Game Scene
A/Dorโ/โ- Move characterW/Space- JumpLeft Click- Use current tool (dig/place/blast)Right Click- View character info and switch controlScroll Wheel/Number Keys- Switch toolsESC- Pause menu
Tools
- Tool 0 - Water placer (place water at click position)
- Tool 1 - Excavator (circular area digging)
- Tool 2 - Exploder (large area destruction + particle effects)
git clone https://github.com/wuxianggujun/Tina.git
cd Tina
git submodule update --init --recursivePrerequisites:
- CMake 3.20+
- Visual Studio 2019/2022
- Windows SDK
Build Steps:
mkdir build && cd build
cmake ..
cmake --build . --config ReleaseInstall Dependencies:
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
sudo apt install ninja-buildsudo snap install cmake --classic
sudo ln -s /snap/cmake/current/bin/cmake /usr/bin/cmake
sudo ln -s /snap/cmake/current/bin/ccmake /usr/bin/ccmake
sudo ln -s /snap/cmake/current/bin/cpack /usr/bin/cpack# Install graphics library dependencies
sudo apt install libgl1-mesa-dev libglfw3-dev
sudo apt install libwayland-dev libwayland-egl-backend-dev libxkbcommon-dev xorg-dev
sudo apt install libx11-dev libxext-dev libxtst-dev libxrender-dev libxmu-dev libxmuu-dev
sudo apt install pkg-configBuild Steps:
mkdir build && cd build
cmake ..
make -j$(nproc)
./Tina| Library | Version | Purpose |
|---|---|---|
| bgfx | latest | Cross-platform rendering (supports DX11/OpenGL/Vulkan) |
| SDL2 | 2.0+ | Window management, input handling |
| SDL_mixer | 2.0+ | Audio playback (MP3/WAV/OGG) |
| EnTT | 3.x | Entity Component System (ECS) |
| spdlog | 1.x | High-performance logging library |
| stb | latest | Image loading, TrueType fonts |
| GLM | 0.9.9+ | Math library (vectors, matrices) |
- Google Test - Unit testing framework
- Tracy - Performance profiler
This project was developed with reference to the following excellent open source projects:
- MitchEngine - Modern C++ game engine
- CatDogEngine - Data-driven game engine
- EraEngine - Vulkan/DX12 rendering engine
- ElvenEngine - 2D game engine
- simple_engine - Simple 2D engine
- Platformer - 2D platformer game
- OpenMiner - Minecraft-style sandbox
- PainterEngine - 2D graphics engine
- 2019-ecs - ECS architecture tutorial
- Spatial.Engine - Spatial engine
- spdlog_wrapper - spdlog wrapper
- klog - Lightweight logging library
The engine adopts a dual-layer event bus architecture, separating OS events and gameplay events:
Handles operating system level events:
- Keyboard events - Key press/release
- Mouse events - Movement, clicks, scroll wheel
- Window events - Resize, maximize, close
Usage Example:
// Subscribe to keyboard press events
auto connection = app()->osEvents().onKeyPressed.connect(this, &MyScene::onKeyPressed);
void MyScene::onKeyPressed(const KeyEvent& e) {
if (e.key == KeyCode::Escape) {
// Open pause menu
}
}Based on entt::dispatcher, for gameplay events:
- Type safe - Compile-time checking
- No engine modification needed - Highly extensible
- RAII auto-management - Automatic unsubscribe
Usage Example:
// 1. Define event types
namespace Events {
struct PlayerJumped { float height; };
struct SetDayNight { float normalized; };
}
// 2. Subscribe to events (using SubscriptionManager for automatic lifecycle management)
TINA_SUBSCRIBE_EVENT(m_subscriptions, Events::PlayerJumped, MyScene::onPlayerJumped);
// 3. Trigger events
Events::PlayerJumped event{2.5f};
app()->events().trigger(event);
// 4. Handle events
void MyScene::onPlayerJumped(const Events::PlayerJumped& e) {
TINA_INFO("Player jumped height: {}", e.height);
}Advantages:
- โ Decouples module communication
- โ Supports async event handling
- โ Automatic subscription lifecycle management
- โ Type safe, compile-time checking
See docs/event_system.md for details
Current Version: 1.0.0
Development Status: ๐ Archived (No longer maintained)
This project has achieved its intended goals as a learning project, implementing:
- โ Complete 2D sandbox game framework
- โ Modern C++17 architecture practices
- โ Cross-platform rendering system
- โ ECS architecture implementation
- โ Fluid simulation algorithms
- โ Complete UI system
The project code is available for learning and reference. If you want to continue developing based on this project, feel free to Fork it!
- Performance optimization - Frame rate may drop on large maps
- Fluid simulation - May become unstable in extreme cases
- UI scaling - Some UI elements may display incorrectly on high-DPI displays
- Audio - Occasional audio stuttering
If you want to learn from this project, it is recommended to focus on the following modules:
-
Scene Management System (
src/engine/SceneManager.cpp)- Scene stack implementation
- Lifecycle management
- View configuration
-
ECS Architecture (
src/ecs/)- Component definitions
- System implementation
- Entity management
-
Event System (
src/engine/EventSystem.cpp)- Dual-layer event bus
- RAII subscription management
- Strongly-typed events
-
UI Framework (
src/ui/)- Custom UI components
- Layout system
- Event handling
-
Fluid Simulation (
src/game/TileMap.cpp)- Cellular automata algorithm
- Water pressure calculation
- Optimization techniques
Thanks to the following organizations and projects:
-
JetBrains - For providing free licenses for open source projects
-
All Contributors - Thanks to all developers who provided feedback and suggestions
-
Open Source Community - Thanks to all the excellent open source projects referenced
This project is licensed under the MIT License.
MIT License
Copyright (c) 2024 wuxianggujun
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
โญ If this project helps you, welcome to give it a Star!
๐ง Contact: GitHub Issues



