< Return to Academics

Burger Time Remake

Project Size
~80 hours
Tools & Languages
C++, Visual Studio
Topics
Engine Programming
Programming Patterns

Assignment

The assignment was split into two parts:
  • Create a 2D game engine using shown techniques (game loop, game design patterns, threading)
  • Remake Burger Time using the engine

Creating the engine was the most important part, while the recreation of this game was mostly to test the engine capabilities and to test problem solving skills. While working on the gameplay, I often found my engine to be lacking features I needed so it was quite a bit of back and forth. The project was implemented following the C++ Coding Standards as much as possible.

Engine Features

  • Game Loop (Update, FixedUpdate, Render & Input)
  • SceneGraph with GameObjects and Components
  • 2D SDL Renderer with depth sorting
  • Input Manager using Command and pImpl
  • Multithreaded Sound System
  • Observer & Event Queue
  • Prefabs

Implementation

Game Loop

The core gameloop is an infinite loop with following steps:
  1. Calculate frame time
  2. Update all GameObjects and their Children / Components
  3. Render visuals to game window

To make sure our main thread does not run all the time, we can implement a fixed or smooth framerate by using the frame time and sleeping for a short time between each iteration.

One more important thing to keep in mind is physics and networking, these should run on a fixed interval. To implement this, simply add another loop which runs while the accumulated time exceeds a fixed timestep.
burgertime game loop Image from Game Programming Patterns, Robert Nystrom

Input System using pImpl

By comparing the previous controller and keyboard states it is possible to know which key is pressed, released or held this frame.

Next, a few steps are needed to set up bindings:
  1. Create a container with keycode, keystate and command
  2. Compare container with keyboard and controller state
  3. Execute the commands

For input actions command classes are used, as they offer an abstract interface for the input system while also being able to hold state data if needed.

The implementation of the input system itself makes use of pImpl, allowing for changes to the implementation and underlying systems without changing the interface.
burgertime inputsystem Image from Game Programming Patterns, Robert Nystrom

Subject & Observer

To implement events, there needs to be a subject observer relationship. The subject needs to know who is observing, while the observer needs to be able to observe the subject.

I chose for an easy implementation, where both Observer and Subject are base classes that can be derived from. The observer can then subscribe to any class that derives from subject, and listen for any notifications sent by the Subject.
burgertime observer Image from Game Programming Patterns, Robert Nystrom

Useful Resources