2D Game Engine


Goal

Creating a component-based 2D engine that also respects some other game programming patterns. The required patterns are as follows:

  • Game Loop
  • Update Method
  • Command
  • Observer
  • Component
  • State

Aside from the above patterns, the engine or game must also make use of threading. The workings of the engine should be proven by writing a small game that makes use of the engine's functionality. The game itself also has a few requirements:

  • At least 3 levels
  • 4 total lives
  • 3 Gamemodes: Singleplayer, Co-op and Versus Mode
  • Sound
  • Playable with both keyboard and controller
  • Highscore list that persists between sessions

The Game

The game I was given to recreate was Pacman. The different gamemodes had to be filled in in the following way:

  • Singleplayer: The normal way to play pacman. The player collects the pac dots and the power pellets while the ghosts are trying to catch them.
  • Co-op: The same as singleplayer, but with two players instead of one.
  • Versus: One player plays the role of pacman and plays as normal, and the other possesses one of the ghosts and tries to hunt down the player.

Pacman Menu

Conclusion

It was very interesting to see how the inner workings of an engine are written. At the start of the project, some of the patterns did not seem that useful, but once I started implementing them in the engine, it became clear why they are used. Setting up The different programming patterns may seem overcomplicated for what it's worth, but once it is, it is the key to working cleanly in a long-term project.