Hi!
I've been doing games as a hobby in c++ for many years, but have little formal programming education. As a result i might have adopted a rather arcane way of structuring my games. I typically have:
1. A master-class called "world" that is huuge. Keeps track of game state as well as lists for units, buildings, projectiles etc. Some things are the same in many games, but i have a unique world class in every game.
2. Typically: cPlayer player[10]; where player[0] is the player itself in a single-player game and the rest is ai/opponents.
3. A main loop where i do stuff like
if(world.running){
if(world.editorOn)
runEditor();
else
runWorld();
}
else
runLobby();
4. Typically entities like "units" have their own functions like unit::update, unit::move etc, but all of this is held together by the "world"-class.
I guess my thinking is very "loop-based" ei sequencial. Is this problematic? I don't think it's a very modern way of coding.
Thankful for any feedback!
Erik
↧