Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualflodihn

Posted 13 February 2013 - 05:55 PM

I made my game client with a slightly modified MVC.

 

The MVC you think of with the database as model usually found in web development does not really suite a game engine, according to my own beliefs.

 

Here is what I did:

MVC+L (Model/View/Controller/Logic) because standard MVC does not state where your logic would fit into the architecture.

 

The model stores all persistent data, such as game objects, mouse pointer, open windows. A game object is a unique id with a number of properties. Like this

{

    id: 1231234

    mesh: "GruntyOgre.mesh"

    pos: 1, 3, 0

    speed: 0

    hp: 100

}

 

{

    id: 231231

    window: "MenuScreen.xml"

}

 

{

    id: 23123156

    mouse_pointer: "green_arrow.png"

    pos: 100, 231

}

It has no functionality other that creating, destroying game objects and adding/removing properties on game objects.

 

The view registers itself on the model and gets notified with game objects are created/destroyed or properties changed. When a game object with a graphical representation (for example having the property mesh) is created, it creates its own graphical object with the same id used to display stuff on the screen (including GUI).

 

The controller listens for input from keyboard, mouse, network etc, translates them to events and forwards them to the logic.

 

The logic is a state machine that does all logic (duh) in the game. It creates, destroys, changes properties in the model.

 

All 4 different layers are completely decoupled and only communicates with callbacks registered in each other.

 

This gives my engine flexibility and some interesting properties such as:

- I can choose not to create a view, thus I can make it easy to create a multiplayer game (if add the feature for the layers to registers themselves on remote machines).

- I can choose to switch resultions and even graphics implementations (opengl/directx) during runtime without having to shut down the game

- I can make any type of game with the engine by just replacing the logic layer.

- I can dynamically upgrade/restart all parts of the game but the model without loosing any game data (since the model is just a stupid container chances are low I would have to update it).

 

On a side effect, this architecture makes it also easy to add and remove features since changes can not cause shockwaves of changes outside their own layers.


#2flodihn

Posted 13 February 2013 - 05:52 PM

I made my game client with a slightly modified MVC.

 

The MVC you think of with the database as model usually found in web development does not really suite a game engine, according to my own beliefs.

 

Here is what I did:

MVC+L (Model/View/Controller/Logic) because standard MVC does not state where your logic would fit into the architecture.

 

The model stores all game objects data. A game object is a unique id with a number of properties. Like this

{

    id: 1231234

    mesh: "GruntyOgre.mesh"

    pos: 1, 3, 0

    speed: 0

    hp: 100

}

It has no functionality other that creating, destroying game objects and adding/removing properties on game objects.

 

The view registers itself on the model and gets notified with game objects are created/destroyed or properties changed. When a game object with a graphical representation (for example having the property mesh) is created, it creates its own graphical object with the same id used to display stuff on the screen (including GUI).

 

The controller listens for input from keyboard, mouse, network etc, translates them to events and forwards them to the logic.

 

The logic is a state machine that does all logic (duh) in the game. It creates, destroys, changes properties in the model.

 

All 4 different layers are completely decoupled and only communicates with callbacks registered in each other.

 

This gives my engine flexibility and some interesting properties such as:

- I can choose not to create a view, thus I can make it easy to create a multiplayer game (if add the feature for the layers to registers themselves on remote machines).

- I can choose to switch resultions and even graphics implementations (opengl/directx) during runtime without having to shut down the game

- I can make any type of game with the engine by just replacing the logic layer.

- I can dynamically upgrade/restart all parts of the game but the model without loosing any game data (since the model is just a stupid container chances are low I would have to update it).

 

On a side effect, this architecture makes it also easy to add and remove features since changes can not cause shockwaves of changes outside their own layers.


#1flodihn

Posted 13 February 2013 - 05:49 PM

I made my game client with a slightly modified MVC.

 

The MVC you think of with the database as model usually found in web development does not really suite a game engine, according to my own beliefs.

 

Here is what I did:

MVC+L (Model/View/Controller/Logic) because standard MVC does not state where your logic would fit into the architecture.

 

The model stores all game objects data. A game object is a unique id with a number of properties. Like this

{

    id: 1231234

    mesh: "GruntyOgre.mesh"

    pos: 1, 3, 0

    speed: 0

    hp: 100

}

It has no functionality other that creating, destroying game objects and adding/removing properties on game objects.

 

The view registers itself on the model and gets notified with game objects are created/destroyed or properties changed. When a game object with a graphical representation (for example having the property mesh) is created, it creates its own graphical object with the same id used to display stuff on the screen (including GUI).

 

The controller listens for input from keyboard, mouse, network etc, translates them to events and forwards them to the logic.

 

The logic is a state machine that does all logic (duh) in the game. It creates, destroys, changes properties in the model.

 

All 4 different layers are completely decoupled and only communicates with callbacks registered in each other.

 

This gives my engine flexibility and some interesting properties such as:

- I can choose not to create a view, thus I can make it easy to create a multiplayer game (if add the feature for the layers to registers themselves on remote machines).

- I can choose to switch resultions and even graphics implementations (opengl/directx) during runtime without having to shut down the game

- I can make any type of game with the engine by just replacing the logic layer.

- I can dynamically upgrade/restart all parts of the game but the model without loosing any game data (since the model is just a stupid container chances are low I would have to update it).

 

On a side effect, this architecture makes it also easy to add and remove features since changes can not cause shockwaves outside their own layers.


PARTNERS