Gamedev Log: “The Escape” #5 (Unity/C#)

A daily log of how I program a basic Unity/C# game: “The Escape”!

This article is also available on Medium.

This week, I’ve started to post my gamedev log on a small Unity/C# game: The Escape.

So far, I’ve prepared most of the basic endless runner game mechanics: we have walls that keep on spawning, we can move around to avoid them and increase our score, and finally we have lasers and coins that pop randomly from time to time.

Today, let’s work on the RPG component of the game: the store! This little “garage” is where we’ll spend the coins we pick up to upgrade our spaceship.

Project rules:

  1. I post a new gamedev log every day with a new demo video
  2. I work 1 hour max per day on this project
  3. I need to have a new visual feature by the end of this 1 hour (it can’t be just bug fix and refactors)

Day #5: Creating the store

Features & demo

The players will be able to access the store whenever they end a run (when the hit the game over). Then:

  • if the player has enough coins, she can buy armour or speed upgrades: the armour upgrade increases the total number of health cells and the speed upgrade makes the ship move faster towards the mouse pointer
  • else, all that’s left to do is do another run and pray that you’ll get more coins!

Today was also a good opportunity to work on my player data load/save system. Indeed, I want the player to keep its armour/speed upgrades when she comes back to the game, and I also want the coin amount to be persistent.

Here is a first run that ends with 2 coins… which is not enough to buy any upgrade!

But the next one ends with me having enough to buy an armour upgrade: you see that after I purchase this in the store, in my next game, I have 4 health cells instead of the default 3!

A few details, tips & tricks

To load and save player data, I’ve used the Unity PlayerPrefs. This class allows me to quickly store the info as an on-disk dictionary of key-value pairs, and it’s really easy to use as its built-in the game engine! Although it’s usually a bit “light” if you want to save a lot of data, or if you have sensitive info that you can’t risk being leaked, PlayerPrefs are definitely a nice way of prototyping the save/load system…

I’ve added a few checks to make sure that when the store opens, the UI only enables the buttons for the affordable upgrades.

Conclusion

As usual, although I have figured out most of what I want to do for this game (in terms of features, gameplay, art style, etc.), I might come up with unexpected ideas along the way… and, of course, I’d be really happy if you’d participate, too, so feel free to leave comments with cool ideas for The Escape!

I hope you’re liking this series of Gamedev Logs, and see you on Monday for the next one 🙂

Leave a Reply

Your email address will not be published.