Back to Projects

Game2025

2D Platformer.

C++SDL2GLMECS

Overview

A 2D game engine built with C++ and SDL2, using an Entity Component System (ECS) architecture. This project is intended as a technical demo and learning exercise, featuring hardware-accelerated rendering, physics-based gameplay, procedural level generation, and comprehensive audio/input systems.

Screenshots

Gameplay
01

Gameplay

Spatial Grid
02

Spatial Grid

Start Menu
03

Start Menu

Game Over
04

Game Over

Project Metrics

ECS

Architecture

Pooled

Memory

Stack

Allocator

Chunk-based

Level System

Key Features

01

Entity Component System

Built a custom ECS architecture with singleton-based managers (Renderer, Audio, Input, Assets), delta-time based game loop, object pooling for entities and resources, and binary serialization for save data.

02

Graphics Engine

SDL2 hardware-accelerated rendering with TGA/PNG texture loading, sprite sheets with configurable clip sizes, parallax scrolling backgrounds, camera with entity following, and logical resolution scaling for resolution-independent rendering.

03

Procedural Map System

Tiled (.tmx) map loading via tmxlite with infinite scrolling using procedural chunk system. Supports chunk types: start, random, gap, and floating platforms with tile collision detection and object layers for spawn points.

04

Physics & Gameplay

Gravity with ground detection, adjustable jump height (hold to jump higher), coyote time grace period, dash ability with cooldown, punch attack with range detection, patrol AI for enemies, health system with invincibility frames, and collectibles.

05

Audio System

16-channel sound effect mixing with background music support (play/pause/stop) and channel completion callbacks for dynamic audio feedback.

06

Input Handling

Comprehensive input system supporting keyboard key down/up detection, mouse position and button states, game controller support, and text input handling.

Architecture

  • Core: GameController, Timing, Singleton pattern for global managers
  • Game: Entity, Components, Systems, ChunkMap, GameUI
  • Graphics: Renderer, Camera, TileMap, AnimatedSpriteLoader, Texture
  • Audio: AudioController, Song, SoundEffect with 16-channel mixing
  • Input: InputController, Keyboard, Mouse, Controller support
  • Resources: AssetController, Resource management, Serializable save data
  • Utils: ObjectPool for memory efficiency, StackAllocator

Challenges & Solutions

Challenge

Creating infinite procedural levels without loading screens

Solution

Designed chunk-based map system that procedurally generates and loads map chunks ahead of the player, with different chunk types for variety.

Challenge

Handling collision detection with many entities

Solution

Built a SpatialGrid that divides the world into cells and tracks which cells each entity occupies. Only entities in the same or adjacent cells are checked using AABB overlap tests, reducing collision checks from O(n²) to O(n).

Challenge

Loading sprites without memory allocation overhead

Solution

Used object pools for Texture, SpriteAnim, and Asset classes to reuse existing objects instead of allocating new ones. Combined with ImageInfo caching and GUID-based asset lookup to avoid unnecessary file access and processing.

What I Learned

Understanding of ECS architecture and its benefits for game development

Gained experience in procedural content generation and level system on a chunk basis

Improved C++ skills including memory management, object pooling, and binary serialization

Understanding of spatial partitioning techniques for efficient collision detection and entity queries

Gained experience with texture loading and sprite rendering

Future Improvements

TODO 01

Add more enemy types with different AI behaviors

TODO 02

Implement power-ups and special abilities

TODO 03

Create a level editor for custom chunk design

TODO 04

Add online leaderboards for score tracking

TODO 05

Implement difficulty scaling based on player performance

TODO 06

Add boss fights with unique attack patterns

Explore more projects