The best way to structure/design game code

Posted by Edward on Game Development See other posts from Game Development or by Edward
Published on 2012-11-27T22:34:31Z Indexed on 2012/11/27 23:32 UTC
Read the original article Hit count: 292

Filed under:
|
|
|
|

My question is quite broad and related to the 2D game code design/architecture/structure.

Usually the main game consists of the main loop where you update & render your world states. However, it's recommended for many purposes to separate rendering from the game-logic and so on.

I am kinda confused about the whole situation. Many game engines/libs/sdks don't follow separation schema. They propagate a way where you define some scenes/stages and they contain some objects and the scene/stage controls the user input and so on. For example, in cocos2d(-x) and libgdx (stage2d) the games are usually done the way that the update logic happens at the same time/place as rendering. Also, the propagated way is to have a structure where an object knows how to draw itself - which is not a separation of updating & rendering. The same with Flash based games, they are usually done the way when an object (class) contains a swf or a texture and some data and holds some update logic itself, or updated from main Scene. And again this object already knows how to draw itself via "addChild".

Also, some people recommend to use MVC pattern, which will require to completely obey the structure of those engines/libs/sdks.

Maybe I am overthinking everything, but I am totally confused.

I would be grateful if somebody could point me to a correct direction with the game code structures. What is your way of doing things in libgdx/cocos2d/flash?

© Game Development or respective owner

Related posts about 2d

Related posts about architecture