[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Underware-devel] Update of MAFApplication and MAFWindow
From: |
Vincent Caron |
Subject: |
[Underware-devel] Update of MAFApplication and MAFWindow |
Date: |
Wed, 31 Dec 2003 15:14:51 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 |
Hello,
in the CVS you can see a working implementation of MAFApplication,
MAFWindow and the modification of Loïc's MVC model to fit in. The scheme
is very simple :
- you register controllers to the application
- you register views to the window
- the event loop is currently very simple :
while(ad infinitum) {
for each controller c, c->Update(app);
for each view v, v->Update(win);
}
It means that a MAF-based game is currently programmed only with
polling functions. The best example to illustrate this is the paddle
handler PongPaddleController::Update() :
--
void PongPaddleController::Update(class MAFApplication* App)
{
if(GetModel()->mMouse)
{
int x, y;
SDL_Surface* win = SDL_GetVideoSurface();
SDL_GetMouseState(&x, &y);
PaddlePos(((float)x) / win->w, ((float)y) / win->h);
}
else
{
Uint8 *keys = SDL_GetKeyState (NULL);
Uint32 delta = GetDelta();
if(keys[SDLK_DOWN]) PaddleDown(delta); else
if(keys[SDLK_UP]) PaddleUp(delta);
}
}
--
The MAFController now keeps track of the Update() call times, you can
grab the delta before last call (0 for 1st call) with GetDelta(). Also
all time values are now using the SDL_GetTicks() type Uint32 instead of
guint. It would be nice to move to MAFTime soon.
PS: I've shamelessly unplugged the Ametista and sound controllers in
PongApplication.cpp, I'll re-enable this as soon as possible.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Underware-devel] Update of MAFApplication and MAFWindow,
Vincent Caron <=