2D Game Engine

University Project

2D Game Engine Screenshot

About this project

Custom built game engine made with SDL 2. It features a Hybrid ECS similar to Unity's and a terraria inspired tilemap system. Part of my C++ course at Stockholm University, we were tasked with creating a custom game engine with 2D-graphics using SDL 2.

Hybrid Entity Component System
Similar to Unity, even the way you program is like in Unity. The core loop follows the init, update, draw pattern.

Core Components

  • BoxCollider2D

    For collision detection

  • CharacterController2D

    For character movement and control

  • InputHandler

    Raw or smoothed input calculated with lerp function

  • Rigidbody2D

    With basic physics simulation

Rendering Components

  • Sprite

    With color, alpha and blend mode modulation

  • Text

    With color and custom font support

  • TileMap

    With bitmasking, basic lighting, and terrain generation

  • Transform

    For positioning and transforming entities

Closing thoughts

This has been a very fun project to learn with, this was my first project in C++ that wasn't plain algorithms or console based. I indirectly learnt a lot about Unity while researching how to make my project's Hybrid Entity Component System. I learnt the way Unity handles entities (game objects) which contain components (scripts).

It would be interesting to expand upon this project when I have more time with a GUI, like a "Mini 2D Unity".

Entity Component System Diagram
Project Details
Team SizeSolo
Start DateJanuary 17, 2021
Duration2 months
ToolsSDL2, C++
View Source Code
Keywords
Custom EngineEntity Component SystemPCGHybrid ECSSDL2C++TilemapPhysics