The game Q*bert made in a custom made engine
The engine is made in C++ using a variety of design patterns.
The main game loop of the engine consists out of: processing the input, updating the application, Updating the scene components and rendering the scene to the window. Delta time is used for frame independant code.
bool doContinue = true; auto lastTime = std::chrono::high_resolution_clock::now(); while(doContinue) { auto currentTime = std::chrono::high_resolution_clock::now(); float deltaTime = std::chrono::duration<float>(currentTime - lastTime).count(); doContinue = input.ProcessInput() && m_Running; GameUpdate(deltaTime); sceneManager.Update(deltaTime); renderer.Render(); lastTime = currentTime; }
Like unity and unreal the engine uses a component based system. You have a basic, empty object called a Gameobject, you add components to this object to add extra functionality. The gameobject has a list of all it's components and will update them when the gameobject is being updated.
The command pattern is used when handling the input. You bind a command, which can take any parameters you want, to a button. Whenever that button is pressed, released or held the command bound to that button will execute. This avoids hard-wiring input to game actions. It also allows to more easily configure how buttons are mapped to certain actions.
The observer pattern has an object called the subject, which maintains a list of observers. Whenever the subject does something that other things should know of, it will notify all the observer it has in it's list. It helps with not having tightly coupled objects.
The service locator is a system that allows you to call a certain service from anywhere in your code without the code having knowledge of it's implementation. The service is an abstract class inside the locator. The user can implement this interface and register the service to the locator. If no service is registered, the service will default to a null service and will not execute any code when called. This will prevent any NULL references or calls. In the engine it's used for registering and getting a sound system. The sound system in the engine uses SLDMixer.
The event queue decouples an event when it's sent from when it's processed. In the engine it's used for the sound system. When a sound needs to be played, it is added to an event queue and is handled on another thread. With this system the main thread doesn't have to wait until it's done handling the sounds and can just continue, while the sound is handled elsewhere.
The game is a recreation of the original 1982 game Q*Bert. The goal of the game, as shown in the gif above, is to turn all the top face colors of the cubes to the same color across the pyramid. The player has 3 lives and gets points by killing enemies and changing the color of the cubes. The game has a single-player, coop & versus mode. In coop mode you will both be playing as Q*Bert, while in versus mode one of the players will be playing as Coily. You can play the game with both a controller and keyboard.
All the source code is available on my GitHub