PlayerName's nth loop
About the game
Engine: Unity
Language: C#
​
Stuck in a never ending loop of death and platforming, the player must find a way to break free from the loop and escape the perpetual torment.
​
PlayerName's nth loop is a Two-Dimensional platformer, created during the Ludum Dare 47 game jam (Theme: Stuck In a Loop).
The team
PlayerName's nth loop was created by myself and a friend (josh). We are both programmers and have worked together a lot over our time at University.
Josh spent the majority of the game jam designing the level for the game, this left almost all the programming to me.
​
I wrote all of the code for the game, aside from the enemies, movement and camera control code.
Programming
The areas that I programmed during the development are:
Scene Management
Collectables
Background Parallax
Time Control
Player Death
Post Processing
Save System
UI
Collectables
To keep the collectable code's readability and simplicity to a maximum, each crystal held an enum value (Standard, Sword, TimeTravel, BreakFromLoop, Sliding, EndGame) which told the Collected() function how to treat that crystal, this allowed all of the crystals in the scene to use the same script, with different values.
​
Below is the code run in Update(), which checks if the crystal can be interacted with, passes the crystals information to the UI, if the player pressed the collect button, then the crystal's Collect() function is run.

Time Control
I really wanted to add the ability to rewind time to the game. I decided the best way to implement this was to store a reference to the player's position, rotation, sprite and rigidbody velocity state every fixed update frame (with a max of X list indexes), then at the player's command, ignore their input and loop through the lists, overriding the player's position, rotation, sprite and rigidbody velocity with the ones stored in the list.
To make this effect look good, I added some post processing (shown in the GIF below).
​
The code snippet shows how I adjusted the post processing over a short time instead of an instant snap.


The code snippet below shows how I store the indexes into each list, checking if the current length of the list is greater than the predefined max length, if true then the new element is pushed onto the start of the list and the last index is popped off.

Player Death
Player death in the game is quite simple, I run a death animation, then lerp the scale of a image mask to hide the game behind a black screen, then I move the player back to their last reached checkpoint.
​
The code snipper below shows the code for the entire death routine.

Save System
Knowing the time pressure of a 72 hour game jam, I chose to implement a very simple, but also effective, save system. My system utilised Unity's PlayerPrefs class. Storing the total number of crystals collected, times reset (death counter), play time, games played and the fastest completed game.
While testing the game I found that I had a lot of fun speed-running the game, so I felt it was necessary to add the fastest run to the game.
​
The code snippet below shows the code used to increment the saved data once the player return to the main menu after a game. The following image shows the main menu stats screen.


Post Processing
Once the player collected the penultimate crystal, death is meaningful, I wanted to show this visually. Using Post Processing I set the game to greyscale and added a vignette. I also dampened the music adding to that eerie feel.
