PeakAEngine:
A 2D Multiplayer Game Engine

Description

During the summer break I decided to take my engine to the next level. Next to improving every feature the engine already had, the biggest change I’d made to the engine was multiplayer support using PlayFab’s services.
As for rendering my engine uses OpenGL3.0 together with SDL, whilst using a combination of SDL Events and Xinput for managing keyboard and controller input. Together with these, I decided to go with SDL_Mixer as a sound system.

If you would like to have a look at the source code, please visit the github repository.

Features

Gameobject - Component System

All game objects are represented as entities containing components. The entity component system is a solid system in a lot of different aspects as it offers a clean design that employs decoupling, encapsulation, modularization, and reusability.

Together with the ECS I also implemented the command pattern. This allows the user to create his own commands, and attach them to certain input events. The input manager will then execute this command whenever the given key has been pressed/released.

On top of that, I also chose to implement the observer pattern. This in itself isn’t the most complex feature out of them all, but it is definitely a nice-to-have when working with f.e, a score system.

Event Driven Engine

One of the things I really like when creating a game are events.
That is why I decided to implement quite a bit of events in my game engine, here’s a list of the most frequently used ones:

  • OnEnable / OnDisable

  • OnTriggerEnter / OnTriggerExit

  • OnCollisionEnter / OnCollisionExit

  • OnBeginHover / OnEndHover

  • OnClick

  • & More!

UI System

When it comes down to developing a game, one of the most important aspects is the user interface. The UI system in my engine is fairly simple, but it does support everything you need such as images, text, buttons, input fields and more!
Obviously it’s important to be able to place the UI elements neatly, whilst taking into account that the window sizes may vary.
So I also decided to have the option to anchor your elements to the most frequently used.

Box2D Physics

As mentioned above the engine supports events such as OnTriggerEnter and OnCollisionEnter. To be able to create these events I am using the Box2D Physics Library to handle all physics and events happening in-game.

PlayFab Services

This is probably one of my most favorite features of my engine.
The way I set it up makes it super easy for the user to register, login, save and or load from the PlayFab Services!
Using the PlayFab Services also provides the possibility to use PlayFab Party!

PlayFab Party

This is actually the reason I decided to revisit the engine, as I wanted it to support multiplayer. The way the engine is set up makes it really easy for the user to create/join any room. After which the events first pass through the network manager. Depending on what event was executed this will be passed on to the game state manager. The game state manager keeps track of all events received during this frame. Any class from the game project can then easily fetch these events and act upon them correctly.

Bonus Section!

This is a little bit of an extra feature I implemented, namely timers.
I wanted to include some sort of replacement for Unity’s Coroutines, so I made a little Timer struct with a function pointer. This makes it very convenient to delay a certain task using nothing more than a simple lambda.

Most Interesting CodeSnippets

Previous
Previous

Not For Sale

Next
Next

Project Factory