Whats my engine about?
My engine started from a Minigin base provided by DAE featuring SDL2 and glm.
On this page I'll discuss some of the features I've added to recreate the game Digger.
Do note that this project remains unpolished, and is put here to reflect personally on what I've done.
I will mostly be talking about topics and features I personally like, features implemented that I will not go into detail about are:
- Game loop
- Multithreading (I will write a short paragraph about this, but not about the content of it in this project)
- Component system
- SDL implementation.
- Commands pattern.
- Controller input though bitmask
- Event listeners
- Decorator pattern (example is logging soundsystem)
- Class based state machines (used in bag)
Grid? Components vs Objects
For the Grid I decided to use the component system and make every tile be a gameObject with a Tile.
This way I could more easily add modular components such as a render component and locations. This only required some logic to control what tile is displayed.
The grid itself is in essence a manager for these unique_ptrs with useful functions such as tile digging aswell as having some static variables to give other actors access to the size of the grid.
grid git .h
grid git .cpp
This system goes hand in hand with the Grid move command which can easily move across the grid, within the screen consuming an X and Y input.
Collision
For collision I decided to experiment with a two way system.
I made a base collision component that checks what collision it has, and what tags it takes collision from.
Something I don't like about my implementation is having to add the collisionTags in an enum class. It requires it to be added in here when making an inherited class from this, which beats the purpose of the inheritance somewhat.
I'd argue a better way to approach it would be to use a tag integer and either using a static container to hold the types, or even go as far as using a multimap to use the 1 key, multiple values feature. I personally haven't tried this but am curious of doing it and will be testing this when school calms down.
Definetily something to reconsider...
An example of UI
I've always enjoyed making systems and experimenting with UI with Unreal and now it's my time to add some own touches.
An example of the UI component would be the ModeSelectComponent.
The part I like about this class is the use of an already existing text component and adding controls to it to cycle through and do gameplay logics.
I think an improvement could be to make it more expandable and reusable. Make a UICycleComponent for example that can go through an array of text with an execute function for when the confirmation is sent when it's active.
Sadly I've not been able to get feedback on this.
Input Backbuffer
A big problem I ran into was adding/removing commands to a controller while one is being executed, which is not as uncommon as you would expect.
The solution to this was to make a backBuffer of commands when a new command gets made, that takes its place between update cycles.
The use of a map came in great as I find it a very intuitive container to use and can easily be replaced with the buffer.
I've been taught about the different containers, but have not been as consciously using them as I should have.
This was a big learning moment to go over the commonly used containers, check their purpose and use them more by purpose and feeling, rather than going to vectors for comfort.
inputManager.cpp
inputManager.h
Important links:
Git repo