Hi,
I'm developing a multiplayer sci-fi game with minimal graphics, in which most game data is shown as text display information and numbers. For example instead of seeing a ship moving through space, the player sees a readout of ship speed on the screen.
When I first started this project a few months back, I stored variables like ship speed, engine power and so on in global variables, which change over time.
This morning I was wondering if this is in fact a mistake, since in my game a player will have the option to buy and own more than one ship. How would I then save the ship stats from the global variables for each ship, as they will be different.
Then I thought, is it a better idea to create an off-screen object which represents the ship, then store the ship stats inside instance variables for the object? The player can own as many ships as he wants and each (invisible) object will contain its own saved stats. This will allow me to decrease the number of global variables in my game by 50% as the way its developing there are a lot of variables going into a single ship which affects the readouts the player will be seeing on the screen. Hopefully this will also reduce the cpu usage?
The same question also applies to things like ship systems for examples weapon fire; their power; rounds and so forth....would I need to create weapon objects too to store these variables, or global? Right now everything in my game is global lol...
What do you think?
Is there a limit yo the number of instance variables an object can carry? I need about 50-100 for each ship (maybe more or less) as I'm making a very complex game.
Thanks for your help.