/ivy-game-engine

Roguelike Oriented 2D Game Engine

Primary LanguageC++Apache License 2.0Apache-2.0

Ivy Game Engine

Ivy is a C++ 2D Game Engine primarily focused on developing Roguelike games.
Currently Windows x64 is the only supported platform.
Features:

  • Custom Entity-Component-System (ECS)
  • Event System
  • Scripting System
  • OBB Collision Detection
  • OpenGL Rendering
  • Procedural Environment Generation
  • Immediat Mode GUI.

Setup

Clone the repository using git clone --recursive to fetch all the required submodules. Run the ProjectGenerator.bat batch file to generate a Visual Studio 2017 project. Make sure to set IvyApplication as the startup project.

Project files for Visual Studio 2017 are generated using Premake5. If you wish to use a different IDE make sure to check these files and update them accordingly.
(Note: The AngelScript module has a number of readily available project files at IvyEngine\vendor\angelscript\projects).

An Application on top of the engine is required to define a class that derives from Ivy::Application and a class that derives from Ivy::SortingLayer. An additional function that returns the newly created Ivy::Application instance is also required.
An example application is provided in the IvyApplication project.

Implementation Details

Logging

The engine uses Spdlog to log internal operations through the use of IVY_CORE_[LEVEL] macros while application operations are logged using IVY_[LEVEL] macros. The logger settings are available in IvyEngine/Core/Logger.h.

Events & Input Handling

The Event System functions according to the Observer Pattern, where Events act as subjects and EventHandlers which encapsulate a callback function subscribe to them. The callback is executed in response to the Event. Currently the engine does not provide a separate phase of Event resolution so Events are handled the moment that they occur.

Input Handling & Window Manipulation for Windows are performed through the GLFW3 library. The source code is available in the Windows package.

Rendering

The renderer uses OpenGL as the primary graphics API with GLAD as the function loader. Currently it is the only supported graphics API.
The engine implements Contexts, Index Buffers, Vertex Buffers, Vertex Arrays, Shaders & Textures.
Commands are issued to the Renderer through the use of RenderCommands. The engine also provides a single Orthographic Camera which can be manipulated by the CameraSystem accessed through the GUI.
Additional functionality is added to the renderer by the Stb and GLM libraries.

Collidable Game Entities Collidable Gizmos

GameObject System

The game object system follows the ECS paradigm and provides a number of readily available Systems and Components.

Systems:

  • CameraSystem
  • ScriptSystem
  • RenderSystem
  • CollisionSystem
  • CollidableGizmoSystem

Components:

  • Collidable (Oriented Bounding Box)
  • Renderable
  • ScriptComponent
  • Tag
  • Transform

Components are aggregated in packed-arrays to maximize cache performance.
Additional Components and Systems can be added by the user as long as they derive from the Component and System class respectively. We provide the UserComponent as an example for user-defined components.
Note that in order to be able to import/export newly defined components the appropriate functions have to be implemented and registered with the JSONManager.
(We recommend taking a look at the json-nlojmann library for more information).

The GUI is implemented using Dear ImGui. It provides easy access to creating, deleting and modifying entities and components.

ECS Menu Collidable Gizmos

Scripting

Game-specific code can be written in C++ or in AngelScript scripts. A number of sample scripts are present in IvyApplication/scripts.

Currently the types the script engine is registered with are the following:

  • Vec2
  • Transform
  • Renderable
  • Collidable
  • ScriptableObject

The ScriptComponent mentioned above merely encapsluates a ScriptableObject such that it can be managed by the ECS.
To create a new script it suffices to create a new .as file and place it in the scripts folder. Script classes should #include 'common.as' and provide a constructor. The onUpdate and onMessage methods can be implement to specify behavior.

Procedural Content Generation

The PCG module is responsible for level generation and uses the Feasible-Infeasible Two-Populations Genetic Algorithm. An Individual is a collection of DesignElements (DEs) where each DE should specify a Tag, a Transform and an associated Entity. The FI2Pop class encapsulates the algorithm which can be tweaked through the Generator GUI.

Note: The LevelGenerator class is responsible for actually instantiating the game objects and should be implemented per project.

TODOs

  • Sound System
  • Animation System
  • Multi-threading support
  • More Gizmos
  • More Collidable Types
  • Support for multiple components of the same type per Entity
  • Layered Rendering
  • Multiple Graphics API Support