2
\$\begingroup\$

I am making a strategy game like Age of Empires. It's a pretty big project and I need a clear game structure.

I have defined a Game_Object class with variables such as:

  • Hit Points
  • Speed
  • Damage
  • Range_Attack

  • ...and a few functions to move the game object, load the game object to the screen, check collisions, etc.

Inheriting from this Game_Object class are:

  • Building_Object (It is buildings in the game to train soldier and villager)
  • Dynamic_Object (It is dynamic objects such as villager, soldier, elephant, bird

I have defined a Civil class, it is a class about the country. It contains:

  • a std::vector<Game_Object*> GameObject containing game objects
  • variables to store the number of resources
  • a few variables about technology
  • functions to check the amount of army units, villagers, houses
  • a few functions to check collisions, update the game objects, move game objects

I have defined a Civil_Computer class, which inherits from my Civil class. It has a few functions to control the nation of the computer opponent.

I also have defined a Manager class, to load the map to the screen, load image, manage game objects, etc. It has std::vector<Civil*> containing the nations of AI and human players, a few function to initialize the game window, check winning, load game object to the screen, etc.

Finally, I have a header file to define many functions such as Move_Object, Check_Alive, etc.

Can someone suggest to me a clearer structure?

\$\endgroup\$
  • 2
    \$\begingroup\$ There's more than 1 way of solving things/tasks and whether your solution is good or not good, and whether it can be solved in a better way, is up to discussion and is based on personal opinions, which this site isn't really about. You should try implement your solution and if you have any issues along the way, feel free to edit your question to aim it against that specific problem and we will be here to help you out. \$\endgroup\$ – Daniel_1985 Dec 1 '19 at 19:16
  • \$\begingroup\$ FWIW, having Building_Object and Dynamic_Object classes is discouraged nowadays, because how will you make an caravan object that can move and create villagers? (Age of Mythology ran into this problem with its "mirror towers", which are actually dynamic objects whose speed is set to 0, and some custom levels give them a non-zero speed, leading to silly results) \$\endgroup\$ – user253751 Dec 2 '19 at 12:16
  • \$\begingroup\$ Thanks for that, do you have a solution for it? \$\endgroup\$ – Traistorm Dec 3 '19 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.