I recently began looking at the less fun and more practical side of my coin system. Namely, how the player collects the coins. Due to my current position as an indie game developer, I don’t know much about collecting currency (still holding out to get sponsored by Waffle House). When a coin is collected it displays the name of the coin, meaning every coin collection is followed by text, so I didn’t want you to be able to technically collect a coin unless you’re in a safe situation. Otherwise, you might miss the chance to read the text before you get killed.

So I made it so when you get the coin you “carry” it until you reach the next checkpoint, where it is then “cashed in”.

However, this presented a few problems, the first of which being that if you die, since you respawn at the previous checkpoint, you inherently touch the checkpoint. This means if you are holding a coin then you die you cash the coin in, which I don’t want.

To fix this I gave each coin a coin ID(™), so when you grab a coin it doesn’t just turn the coin into a “following coin” but it also creates an invisible placeholder where it used to be. The coin then stores the coin ID in an array of “coins you are holding”. When you reach a checkpoint it goes through your holding array and puts each value into a global collected array. However when you die it clears your holding array before you touch the checkpoint, thus not storing any of the holding coins into the collected global variable.

Then when you walk back into the room that has the coin that you collected, now it just has a placeholder, the placeholder then checks if it’s coin ID is in the global.collected array. If it is then it goes the way of the dodo, otherwise, it turns back into a real coin. The end result is that when you grab coins if you make it to a checkpoint then you collect them if you die they return to their original position.

If you are interested in following this game’s development more you can look at our Twitter or Instagram. And there is a demo of the game if you want to try it out for yourself