Survival games are an extremely popular genre, and they give excellent opportunities for IAP monetization thanks to a rich variety of items. I had an experience building a survival game recently and wanted to share it with you to help you to avoid many pitfalls.
If you come up with any questions while reading this, message me on Linkedin, and let’s chat.
What are the problems and risks?
Any survival game is built around lots of items. Let’s see what you can usually do with items in such games:
- Consume: a bottle of water or a piece of meat.
- Equip: clothes, weapons, bags.
- Use as additional storage: bag.
- Deal damage: swords, bows, guns.
- Learn something: scroll, book.
A reasonable question to ask is how you are going to implement such a system of items. Keep in mind that as the game grows, the list of items and what you can do with them will grow as well.
Take a moment to think before reading further. I’ll start with the wrong solutions to make a comparison. When I was younger I used rather bad practices in my own games, but I’ve learned a lesson. However, I also know that other developers are still using these approaches.
Wrong solution #1
Make a huge table assuming that each item has parameters for all possible use cases. It means that you’ll have an item class with tons of parameters. Why this is bad:
- Very soon you’ll find yourself having a table with hundred columns. It’s very hard to work with such tables, and the worst part is that, in most cases, you won’t be using 90% of the columns.
- The size of your data grows dramatically with each new item or game feature.
- Programmers don’t like classes with a hundred different parameters. It’s hard to work and scale.
Wrong solution #2
Inheritance. You can define a base class item and inherit other types of items from it: ItemWeapon, ItemConsumable, ItemBag, ItemBook, etc. This sounds like a good solution at first, but wait… it’s not.
In the past, I was working on a game that had many spells. I did a mistake and used inheritance for the spells system:
- FireBall : SpellBall : SpellBase
- FrostNova : SpellArea : SpellBase
Later when we had more than 10 spells I realized that inheritance doesn’t work. Sometimes you have a spell, which needs to be inherited from 2 different classes. This solution was hard to scale.
The same will definitely happen with a survival game.
Finally – the solution!
Composition is the solution I found to be perfect for most cases. It will work for the Item system in a survival game and for any spells system.
- Create a class Item with basic parameters: Icon, Name, Description, etc.
- Add a parameter Actions – an array of a new class, let’s call it ActionBase.
- Then you create many derived from ActionBase classes — one for each possible usage of an item: Consume, Equip, Damage, Read, Construct.
- When you need to add a new action for any item, you just need to add a new class of a proper type to the list of actions.
You can see in our table above many types of actions: Consume, Recycling, Special, Wearable. As of today, the game has 27 different actions! Look how convenient it is to add, view, and edit all these actions right in the table.
It’s up to you how to write the logic for the data we created together, below is an example of how you can check if the item has a specific action:
Conclusion
Composition works great not only for items and spells, but also for tutorials, quests, offers, events, etc. Take a look at how we designed tutorials in our game:
The whole tutorial can be designed and changed fully remotely. It also means that we can create many different tutorials and run A/B tests without headaches for the programmers.
What’s next?
Being a fan of video games, I always wanted to push the gaming industry forward. As a next project, I want to make a simple prototype for the in-game shop, where each offer can be activated depending on certain conditions. I’ll show you how you can design such a feature in a very convenient way. But the hardest part is that I want to fill it with data from a popular game, so I need to make or find a deconstruction of such a game.
All the sources and tables for this prototype will be available to the public. If someone likes this idea, please contact me and we can make it together!
Survival game from the article: GooglePlay.
Tool to work with game balance: Balancy.