James Keats

Game Programmer

Graphics & Game Engine Programming I - Platformer & Level Editor

Final Project

Our final project for Graphics/Game Engine Programming I had, among many others, the following requirements:

  • Must have powerups and pickup items--powerups affect the player and gameplay, pickups add to a score.
  • At least 2 enemy types.
  • GUI elements.
  • Background elements and effects.
  • An animated main character with collision.
  • A working, in-game level editor.

Graphics & Game Engine Programming I had us essentially build a mini platforming game engine over the course of the semester in C# using MonoGame. This project was the final culmination of all of that work.

There was absolutely no copyright infringement in this class or this game.

This project focused more on the Game Engine portion of the class than the Graphics portion, but I did my best to incorporate my graphics learning as well. One of the important things I took away from this class was composition over inheritance, although looking back on my code there are plenty of things I would've done differently with respect to this. For example, my characters had a collider component (good) but they inherited from AnimatedSprite (bad) rather than containing a sprite or rendering component. A lot of the more advanced architecture-related learning was done the following semester in Game Architecture, but we learned a lot of important Game Engine concepts here.

One of the effects I used for the background was parallax scrolling...

...which is a little hard to demonstrate with still images.

In terms of graphics-related effects, some of the ones implemented for this project were the scrolling camera with parallax effect, and particle systems. The parallax effect is demonstrated in the images here; you can see that the dark background mountains move slower than the light foreground mountains which move slower in turn than the interactive level area. This effect is done by scaling the camera's translation Matrix using MonoGame/XNA's "Matrix.CreateTranslation()" function. The scaling is done at different rates for each of the different levels of background.

Simple coin "explosion" particle effect.

This game also involved a very simple coin "explosion" particle effect. While not particularly impressive by itself, it gave me important insight into how a general particle system is made and triggered. This knowledge came in very handy when working on my summer game engine project. In this implementation, the overall system consists of a Particle class which simply contains a sprite, velocity, position, and lifetime. Above that is the ParticleController, which handles creation of individual particles and destroying them after their lifetime has expired. In this implementation, they actually get destroyed--in my personal project, they get released in an object pool. Finally, there's the ParticleEmitter--or, more accurately, ParticleSystem--class which handles creation of the controllers and manages an actual effect through its controllers.

The final requirement of this project is the level editor, which was a lot of fun to make. It essentially involved creating a whole separate state for the game to be in, something that I had no experience with beforehand. Because I had no knowledge of Event Systems or Observers at the time, the code is a little hard to read. The main "Game" class, for example, is over 750 lines of code. All of the input is done through polling, and some of the conditional logic is... impressive? Still, it's a fully functional in-game level editor with lots of features:

  • Place four different types of tiles*
  • Place coins, powerups, and move the level's end point.
  • Place two types of enemies.
  • Move the player's starting position.
  • Clear, save, and load custom levels, and reset levels to their default.

One of the systems that took a lot of work was the tile placement. When I say four types of tile, I mean four visual styles of tile. Each of these styles has 9 different pieces (up-left, up, up-right, mid-left, mid, etc.). I attempted to develop a system that correctly set the pieces to their correct tile without any guidance from the player; all you had to do was set up a block of adjacent tiles of the same style, and the game would automatically determine the correct block type. It worked perfectly fine for any rectangle shape, but sometimes would get a little weird with other shapes, which is somewhat unavoidable without any interior tiles. Still, I'm proud of this extra little graphical touch which was not a requirement of the project.

One of the interesting parts about writing these portfolio pieces after the fact is seeing all of the things in all of my projects that I would do differently in retrospect, which is one of the fun but frustrating parts of still being deep in the learning process. Despite there being many aspects of this project that I would change, this is where a lot of the solid programming concepts and patterns were first being set down for me. Even though it consists of a random hodgepodge of free online assets, the final project looks surprisingly good graphically. All-in-all, a good result for a Graphics I class.



Desktop Site