Oh God Why is a difficult game. I wanted to make a hard-as-nails platformer similar to Team Meat's Super Meat Boy but without having to spend huge amounts of time designing levels, so I decided to make the levels procedurally generated based on my own algorithms. The aim of the game is to get as high a score as possible by collecting the gold scattered throughout each level. The difficulty comes in the hundreds of spikes covering the floors, ceilings and walls of each level.
A level consists of four rooms connected in a clockwise fashion. You enter a level in the top left room and have to make your way to the exit in the bottom left. Each room has 20 gold pieces worth 10 points each. If you collect all 80 of the gold pieces in the level you get 200 bonus points at the exit, meaning there are 1000 points available per level. Reaching the exit takes you to the next level from which you cannot return.
Gold is also the only way to recover health. Each gold piece heals you by a single health point (up to the maximum of 100). Touching a spike deals 10 damage, along with a knockback effect and a short period of invincibility.
You can move left and right and have a variable-height jump (hold the button to jump higher) but the key tool is the grappling hook. The grappling hook fires directly upwards and latches on to the nearest ceiling, allowing you to swing across spikes and gaps. You can also ascend and descend the grapple to climb out of pits and carefully lower yourself down into unseen danger.
I designed several algorithms for the various phases of the generation process, which results in unique and challenging levels every time. The first phase is generating a tile map for the level. The second phase is to efficiently create Box2D bodies which represent those tiles in the Box2D world used for collision. The third and fourth phases are to place enemies and collectables throughout the level.
The secondary thing I wanted to focus on was reading and writing data to and from a file. This game was made for the PlayStation Vita using a basic framework set up by one of my lecturers for the really low-level stuff, including loading in files, but he hadn't done writing out to a file. Since Oh God Why is a game about getting the best score possible, I knew it would be greatly improved if the highest scores were properly tracked. Having the ability to save as well as load data also meant that it would be possible to save the state of the game and resume at a later date.
For about a month during term-time I spent most of my free time working out how to get the save data functionality up and running. I was reading through the official Sony Computer Entertainment documentation as well as reading, modifying, breaking and fiddling with the accompanying sample code. After several false starts during which I had great help, advice and anecdotes from my lecturer, I eventually got it working. My lecturer also helped to integrate the resulting SaveManagerVita class into the framework he developed, including getting the dialog windows to render. This whole process was extremely fun and interesting and to have proper working save data on the PlayStation Vita was well worth it. I later went through a similar process working with my lecturer to get the application to run as a stand-alone piece of software, meaning it could be installed and work on any PlayStation Vita, not just a development kit. I learnt a lot here too and after a while we got that working as well. I took the opportunity to test out the save data functionality on a retail Vita and it all worked as expected: when the application started up it checked for existing save data and either created or loaded it in, and data was automatically saved (overwriting the existing save file) when the player died or manually saved the game. Having automatic saves and loads was functionality that I created myself; it wasn't in the documentation or sample code.
I'll be writing some more about Oh God Why, including how I utilized the features of Box2D and an in-depth look at the different phases of the level generation process, as well as anything else that comes to mind about the project. For now though, a screenshot dump (click to enlarge):