Is it practical to have two instance of a Game class object

Started by
8 comments, last by Hodgman 10 years, 2 months ago

Wow! A lot of response! I did not expect this. Okay I will keep my Game class open as not a singleton. Thanks for the practical scenarios on two instances of the Game class object.

Advertisement

Even if you can't think of a scenario where you might want more than one Game instance, keep the possibility open.

This! Don't prevent yourself from making additional instances because you can't currently think of reasons you might need them. By not imposing an unnecessary restriction on your code now you allow yourself greater flexibility if you find the need for an additional instance in the future.

This! biggrin.png

Another example -- to diagnose problems with networking, I have seen a games company simply instance two copies of the entire game-client within the one application, and hook them up via the networking system. They even plugged both instances of the game into the one scene renderer (tinting the objects from one of the clients a different colour). This let them visualize the state of a two-player network game using only a single PC, and whenever a desync bug occurred, it was immediately obvious (as a player/game-object would 'split' into two different locations on the screen).

The game wasn't initially designed to be used this way, but because it was written using clean and sensible software engineering practices, it was very easy for them to implement this "multiplayer testing" feature later on.

This topic is closed to new replies.

Advertisement