top of page

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).

PlayerName's Nth Loop: Bio

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.

PlayerName's Nth Loop: Text

Programming

The areas that I programmed during the development are:

  • Scene Management

  • Collectables

  • Background Parallax

  • Time Control

  • Player Death

  • Post Processing

  • Save System

  • UI

PlayerName's Nth Loop: Text

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.

PlayerName's Nth Loop: Text
Collectibles_CrystalSelection.png
PlayerName's Nth Loop: Image

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.

PlayerName's Nth Loop: Text
TimeControl_PostProcessing.png
PlayerName's Nth Loop: Image
TimeControl.gif
PlayerName's Nth Loop: Image

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.

PlayerName's Nth Loop: Text
PNL_TimeControlDataStore.png
PlayerName's Nth Loop: Image

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.

PlayerName's Nth Loop: Text
Reset_ResetAnim.png
PlayerName's Nth Loop: Image

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.

PlayerName's Nth Loop: Text
SaveSystem_ReturnToMenu.png
PlayerName's Nth Loop: Image
MainMenuStatsScreen.png
PlayerName's Nth Loop: Image

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.

PlayerName's Nth Loop: Text
PostProcess.gif
PlayerName's Nth Loop: Image

Source code

To view all of the above scripts, along with many unmentioned ones, that I created during the development of 'PlayerName's nth loop', click the button below to go a GitHub repository with all of the .cs files.

PlayerName's Nth Loop: Text
bottom of page