ratchetfreak
MVC and all the related MV* patterns IME boil down to the same thing:
A model with the data you want to expose through an interface (the View). The interface can be a GUI, a C-api, a web-api, ... It is usually standardized in some way and dependent on the usage of it. So it makes sense to separate the model's design from the View's.
To expose the model through that view you need some glue code that's the "controller" or "view-model" or "presenter".
It doesn't matter how you name that glue code or which minutia change between them it's still a bunch of data and operations on that data getting exposed through an interface.
I have done the hard separation between model and GUI code before by separating the projects and only having a dependency going one way. Using that I have been able to reuse the model code wholesale in related projects that needed to read the files the first project wrote out.
Hi, the last 10 years I programming on PHP, now I returning to programming on c/c++ to learn to make a game, because this, what I thinking now can be very wrong.
I concert with you about MVC and how to do.
I do my own framework using MVC on PHP and this help me a lot.
Ok, I trying a idea here, but I don't know if this a good idea.
[CORE]
The game engine.
Router:
Where are the main loop.
Will control the call of the child-controls, your life time, your constructs and destructs.
Control:
Have the tools to child-control make you job, read all the inputs, call child-models and child-views, control some the statements, thinks to help on decisions.
Model
Tools to help child-models like, load assets (image, audio, xml, etc), save files, interpret scripts, serialize of data, memory, convert datas
View
Tools to help child-views like, make the window, rendering all the things, animate, play the sound, make the controller shake, light, shades, fonts
[childs]
The game, can be a scene, menu, action, etc...
A example of this things
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 | class SceneIntro_model : public Model{
public:
int loadMap32(){
this->loadOBJ('texture.bmp');
this->loadIMG('texture.bmp');
//some calc
this->rules();
}
int newJump(){
//some math
}
private
int rules(){
this->loadXML('mechanics.xml');
//make some calcs
}
}
class SceneIntro_view : public View{
public:
int makeMap32(){
//put objects, make the math happen
//put the result of the calcs
this->light();
}
int jump(){
//put objects, make the math happen
//put the result of the calcs
this->light();
}
private
int light(){
this->changecolor(bla bla bla);
this->putLight(x,x,x,x,x);
}
}
class SceneIntro_control : public Control{
int index(){
//This can be a function of the main Control like this->loadModel('name');
this->model= new SceneIntro_model ();
this->view= new SceneIntro_view ();
this->model->loadMap32();
if(this->controller(Press_X)){
this->model->newJump();
this->view->jump();
}
this->view->makeMap()
this->view->render();
}
}
class Router{
Init(){
SceneIntro_control *control;
control = new SceneIntro_control ();
control->index();
}
}
|