this post was submitted on 16 Dec 2024
18 points (100.0% liked)
Game Development
2814 readers
6 users here now
Welcome to the game development community! This is a place to talk about and post anything related to the field of game development.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Pretty much, yes. I generally have such few item types in my game that it doesn't really matter if I hard code them.or not.
For example, Item might contain parameters like item-id, item name, carry weight, etc. Parameters that every item would need to have. Then HealthItem would inherit from Item, and thus would include all its base parameters and methods for being added to the inventory, etc. HealthItem would then also have new parameters like heal-amount and a method for healing its user.
Something like a health potion that heals 5 health and a medkit that heals 50 health would both use the same HealthItem class, and be stored in the game engine as separate prefabs. These prefabs would then be instantiated into the game for entities to interact with them.