mvc view

Unfortunately online games are much more complicated than just “putting the model on the server” as you say. It might work for simple games and some edge cases (turn based games perhaps) but once you get beyond that and want to do more involved things like client-side prediction, lag compensation, etc. then you end up needing a larger and larger amount of state available on the client. And arbitrary divisions into M, V and C start to hinder instead of help.

[quote]If you don’t succeed in dividing several aspects in your game in order to apply MVC, it might mean that something is wrong in the design of your application, it might mean that some aspects are too tight because of the way you designed it or the way you implemented it whereas it should be easier.
[/quote]
Arbitrarily picking MVC (assuming you can find a definition you like) and sticking to it religiously does not mean your design is any better. I’ve tried MVC for games several times before and for anything non-trivial all it does is introduce false dependencies and arbitrary (and unhelpful) divisions in code. Far better to adapt your architecture based on the demands and needs of your particular game. I can get looser coupling, less dependencies and an overall better design by avoiding MVC.

For the record, sometimes Tang and I respectfully disagree, but this time we don’t. It’s a good thing. :slight_smile:

I disagree with Orangy Tang first statement and agree with the second.

esp with client side prediction you want clear structure. This is because to make sure the prediction is correct or need to be corrected you need a clear separation between different data types predicted, client side calculated and all overriding server side(or similar grouping that better fits your needs algorithm). eg classification. Having some MVC alike structure helps. I think your guys are getting stuck here on the fact that there should be one View one Model one Controller, perhaps on one layer of abstraction, but hell I can’t even write a simple business application without applying it on a couple of layers. It’s a design pattern the implementation can be different every time and a design pattern only specifies how components manifest themselves from a outside view-in. It rakes “I’m going monolithic cause it’s simpler”

I have never said it is simple but it helps.

ok, so I made my turn based game, client/server with cmv.

Defenitions:
ClientModelController: Take gui pixel locations/network col,row locations transform them to Tiles call GameController functions
ServerModelController: Take col, row locations, transform to tiles call GameController functions
GameController: Take Tile positions, make game changes holds game Logic

So far the GameController didn’t do anything else then changing the game.

But now I want to add a ‘travel over active units’ function so when i press tab the next unit is selected, where would I put all the units of a player?
Can a GameController have a get function? like getUnits(Player p)
and then store those in clientModelController? :-\

here is the src of the GameController:
http://jadvancedwars.cvs.sourceforge.net/jadvancedwars/trunk/src/common/controller/GameController.java?revision=1.9&view=markup
and of the ClientModelController:
http://jadvancedwars.cvs.sourceforge.net/jadvancedwars/trunk/src/client/controller/ClientModelController.java?revision=1.10&view=markup

The player class atm contains only player data like.

  private int id;             // Unique Number for identification within a map.
  private String name;        // Unique Name for this player, used in the gui
  private Color color;        // Unique
  private int budget;         // Amount of money that can be spend

So it’s not an option to store in there.

I know how to code the function, just not sure where to put the units/player

I’m not sure but it should be in the model.