2D C# Game Engine – University Final Year Project

For my final year project for my computer science course at the University of Hull, I created a 2D component-based game engine using C#. During the project, I wrote a series of reports, describing the current state of the project. The final report, along with the rest of the project is available on my GitHub profile. For a detailed breakdown of the project, I would recommend reading the final report. However, for a summary of the contents, I have provided the following sections from it:

“In standard object-oriented design, inheritance and subclasses are used to provide specific behaviours, data and logic for objects within a program. This is not a very practical approach for video games, because of the variety of different objects that are required – leading to an explosion of subclasses and as a result, redundant duplication of logic occurring even in objects which do not require that logic. […] This forces the software designer to move most functionality to the top, making the structure very ‘top heavy’. Methods need to be put in places of the hierarchy in illogical locations because of where they are in the class tree, rather than because of what they are. This can obviously lead to disorganized and messy code that is very difficult to work with.

One solution to the problem of class explosion is the ‘Game Object Component System’. This system removes game logic from game objects and moves it into aggregated components, which are assigned to a simple game object. […]

In this architecture, because logic is no longer held within game objects, components are used by ‘systems’ which implement behaviour based on the data found in components. For instance, a texture component simply holds the data required to render a texture. The Render system takes the texture information from the texture component and uses that to render the texture.”

This covers the basic concept of the project. This, along with other projects completed for my University course lead me to achieve a 2:1 in my degree.

C++ Sudoku Solver Using Pointers

As part of my Advanced Programming course at the University of Hull, I was tasked to create a program which can solve a Sudoku puzzle*. This program was required to read in a plain text file which defined the puzzle and then immediately solve it as quickly as possible. While it may not have been the most intuitive or user-friendly design, the point of the program was to implement a given data structure using C++ pointers to define the puzzle.

The program reads in the puzzle and stores each ‘square’ of the puzzle as a ‘cell’ object, which holds the value of the cell, whether it was given or not and a list – known as the ‘candidate list’ – which holds every possible value that cell could be. Each cell is then referenced by an array of pointers which define each row, column and block of the puzzle. This allowed me to easily implement a solving algorithm which uses, basically, a process of elimination to find the solution to the puzzle.

If the given puzzle is solvable, this program can solve it with a 100% success rating in my testing. Thanks to the efficiency of the data structure using pointers, my program can solve a puzzle with an average of 0.000086 seconds and 0.000123 seconds at the slowest**.

My code is available for download if you want to examine it for yourself and see the program in action.


* The algorithm and data structure were designed by Dr J Rayner of the University of Hull and given to me so I could implement it as part of university coursework.

** Timing is based on my own testing and was recorded by the program as a floating point variable to 6 decimal places.

2D Graphics JavaScript Animated Image

In 2016 I, for my university coursework, was tasked with creating an animated image using JavaScript. I was given full creative licence to create an image of whatever I wanted to. Seeing as 2017 was to be UK City of Culture, and I was (and still am) attending the University of Hull, I decided to create an image of the Humber bridge. The image is simple and the colours are abstract (many of my friends have pointed out that the bridge being red makes it look like the golden gate bridge), but I am pleased with the final result.

I would embed the JavaScript canvas object directly onto this web page, but unfortunately, WordPress.com doesn’t allow bloggers to embed JavaScript into their posts, for some quite good reasons. I have resorted to a short video for you to watch. You can also download the source files to have a look yourself if you’re interested in that sort of thing. 

So for a quick breakdown of what this is. This is a vector-based 2D animation using requestAnimationFrame() with CPU-independent animation. The birds are drawn with a sprite sheet that looks like this:

bird-sheet

Each bird is a frame of the animation. Every update the image changes to the next sprite creating the illusion of a flapping bird. I have also implemented parallax – the bigger birds move faster than the smaller birds. The image is also drawn and animated using a custom-built scenegraph and the canvas API in HTML5. The Vector and Matrix classes are also coded from scratch by me.

This coursework was marked and the final score was 87%.