The following is specific to my problem, but I believe the principles can be applied to any game.
I am currently working on a 3D game which will have many different types of spaceships. The physics and behavior of the spaceships are controlled by a base 'Ship' class. This base class in turn derives from a 'Drawable Object' class which handles the transformations and drawing of the ship.
I want the spaceships to have a set of stats such as
- Max speed
- Cargo capacity
- Weapon power
- etc
that can be passed into the physics and behavior functions.
However, during gameplay new spaceships will be able to be bought/upgraded, but i want to be able to pre-define a (possibly large) list of setups that will be available to the player.
What is the best way to store the available stat setups?
Should I be using a large JSON/XML file or similar to store the stats which is loaded at runtime? Or might I just as well hard-code the stats into the constructors of a set of derived classes?
The actual physics attributes (location, velocity etc) and its stats of a particular spaceship are being saved to file when the game is actually played.
I have researched about entity-component-system architecture, but I haven't found much about how to define these entity stats.
Any advice on improving my entity architecture would be much appreciated - this is one of my first attempts at hobby game development.
Answer
Having the ship stats in an external file would likely be a lot easier to maintain.
- You can modify values without having to recompile your game binary
- When you are working in a team with non-programmers, these can be taught how to edit these files on their own and contribute to the game balancing. It might even enable them to add and remove ships without help of a programmer.
- When you pick the right format, editing the values will likely be a lot more convenient because of less language syntax around the actual values (this problem can be better or worse depending on what programming language you use. For example, when you use Javascript, a JSON config file and a file which initializes an object with fixed values is exactly the same thing)
No comments:
Post a Comment