Need help to design a module and scalable Power Up system
Hi, I am trying to switch to game development as a programmer (I have worked as a web developer before). I am new, and I'm working on my first few projects. The goal here is both to learn the best practices, as well as to prepare entries for my portfolio.
Currently, I am working on a endless runner, where you avoid obstacles and collect coins. I am trying to introduce a power-up system that will give the player many kinds of temporary powers/benefits.
As I mentioned, I am trying to work on this project in a way that prioritises learning the best practices and architecture, following proper OOP practices and SOLID principles (which I am new to, at least at implementing). I want to learn to write code that can be easily understood, scaled, and maintained.
I have come up with an initial idea of how to approach my power-up system, and i need reviews and suggestions
The types of power-ups I have come up with (and will come up with) might fall into different archetypes, which need to be supported. The two archetypes I have as of now are:
- Powerups that only expire naturally when their duration expires (and can not be deactivated before)
- Powerups that can get deactivated before their duration ends, if certain conditions are met (e.g. Shield powerup gets deactivated if the player gets hit)
I have thought of a way to make this work, but I am not sure if that is the ideal way to do it.
My current idea:
- There will be an IPowerUp interface that will contain all common properties of powerups of all archetypes
- Each archetype will be represented by an abstract class, which will extend IPowerUp. Each of these base abstract classes (representing archetypes) will have generic methods (e.g. logic for activation, natural expiry, forced deactivation on certain conditions, etc) that will be used by all different types of powerups that fall under that specific archetype.
- There will be a PowerUpManager script that will manage the power-ups.
Am I approaching this with the right mindset?
Please suggest improvements/details that will help me figure out how to approach this mentally. Any help is appreciated. Thank you.