Proton2D is a simple open-source game engine specifically designed to make 2D platformer games.
The main features of the engine are:
- Game Editor written using ImGui library,
- Entity Component System (ECS) architecture powered by the EnTT library,
- External Physics Engine Box2D,
- Prebuilt Entity Components,
- Scenes system to manage game entities,
- Native C++ Entity Scripting,
- Spritesheet support,
- Spritesheet Tile-based Animation,
- Resizable Sprites using the 9-scaling method,
- Entity Prefabs (will be reworked).
At the moment, the Proton engine is compatible with Windows only. Linux support is planned to be added in the near future.
Proton uses the git submodules, therefore repository cloning should be done with the following command:
git clone --recursive https://github.com/Proton2D/proton
If you happen to clone this repository non-recursively, use git submodule update --init to clone the necessary submodules.
Build configuration tool: Premake 5
Supported platforms: Windows
Run the Win-Build-VS22 script to generate solution files for Microsoft Visual Studio 2022 via Premake5.
Run the Win-Build-Game script to build and copy the game executable and content from the project directory to a separate output build directory. You can choose a project by providing its name, the configuration of the build, and the target output directory. Default values can be modified inside the script. Proton does not currently support binary asset packing, all files from the content directory will be copied directly to the output directory while running the script.
There are three types of build configurations in Proton2D:
- Debug configuration: This build is intended for development and debugging purposes.
- Release configuration This build offers more optimized performance than the debug build, while still retaining the full functionality of the game editor.
- Distribution configuration: This is the deployment-ready build, optimized for end users. It excludes a game editor, ensuring an efficient application.
The Proton2D game engine architecture is mainly based on the Hazel Engine architecture. The resources and materials provided there by the Cherno helped me learn a lot about the game engine and software architecture, which I am very thankful for. I highly recommend checking it out for anyone who is interested in the game engine architecture. Note: I am not an expert game engine developer, this is just my personal project that I worked on, and I will continue working on for some time.
Modules as
Renderer,
Event system,
Debug utilities and implementation for Windows
Input and application
Window were directly copied from the Hazel source code with some slight modifications. The organization of code into modules, represented by the src/Proton directory structure, closely resembles the structure found in Hazel and other game engines.
Most of the libraries used in Proton are also used in Hazel.
The only difference is the library for entity serialization, which Proton happens to use, is the nlohmann/json library.
The src/Proton directory was divided into the following modules.
| Module | Short description |
|---|---|
| Core | Core engine components like the Application class, Window, and Input interface. |
| Debug | Spdlog logger wrapped with macros. Better assertions that use debugbreak. An Instrumetor class for measuring code performance. |
| Events | Event system for handling events with the EventDispatcher class. The module contains window, key, and mouse event classes. |
| Graphics | The module features a 2D Batch Renderer from Hazel engine. Additional classes are: Sprite, Spritesheet, ResizableSprite, SpriteAnimation, Camera. |
| Scene | Scene module contains ECS integration consisting of Scene class which manages entities on the screen and owns entt::registry, an Entity class wrapper which provides several methods to make changes to components associated with an entt::entity. The Components.h file contains all the available components that can be added to an entity. This module also contains utility classes like SceneManager to manage game scenes and PrefabManager (will be reworked) to create entity prefabs. |
| Physics | Integration of the Box2D physics engine. The components for entities are RigidbodyComponent and BoxColliderComponent. |
| Scripting | Contains an EntityScript base class and the ScriptFactory for keeping track of created EntityScript derived classes and creating appropriate instances by providing script class name as a string. Scripts are at the moment written natively in C++. |
| Assets | Contains very basic AssetManager class to manage game resources and a SceneSerializer class to serialize and deserialize scenes and entities. |
| Editor | Game editor interface implementation using the ImGui library. |
The Proton2D game engine editor consists of several panels, each having it's own unique role in the game development process.
| Panel | Short description |
|---|---|
| Scene Hierarchy | Manages the scene's entity hierarchy structure. Right-click to add a new entity at the scene root, or click on an entity to add a child. Entities can be reorganized through drag-and-drop. |
| Inspector | Panel where you can edit entities by modifing their component values. |
| Toolbar | Scene simulation control buttons: Play, Pause, Resume, and Stop. Loaded scenes tab bar. |
| Viewport | Scene viewport that displays a rendered game view. You can move the editor camera by holding the right mouse button, and select and move entities using the left mouse button. Camera zoom can be changed by using the scroll wheel. |
| Content Browser | Browser for game "content" folder which stores all game assets. Prefabs and Scenes have implemented drag and drop functionality. |
| Settings | General application and editor settings. |
| Info | Frame time, FPS, Renderer stats. |
The editor is integrated into the game runtime and not built as a separate application, because the engine does not have external language scripting nor hot reloading implemented yet.
Proton at the moment, offers only Native C++ Scripting. To create an entity script, you must create a class that derives from the EntityScript base class. Inside the created class, a macro ENTITY_SCRIPT_CLASS(class) must be placed (under the public members). It will register a script inside the ScriptFactory class.
The approach of native scripting has the disadvantage of requiring a recompilation and restart of the application for script changes, as it cannot hot-reload scripts during runtime. Native C++ scripting however, is generally faster in terms of performance than external language scripting. The external scripting engine will probably be added in the future. It was not implemented yet due to the lack of time.
The sandbox is the project in which the game is developed. It contains an example game made in Proton2D. Window properties can be changed by modifing the sandbox/app-config.json config file. A proper script for creating new game projects from the template will be added soon.
The current goal of the project is to have networking implemented and a basic game UI system. Additional features and enhancements to the editor will be implemented as well. The work will be primarily done in a private branch. This branch will also receive updates from time to time.
© Licensed under the MIT License.
