2009-11-23 20:47:01 +01:00
|
|
|
#include <SDL_image.h>
|
|
|
|
#include <SDL_ttf.h>
|
|
|
|
|
2009-12-06 10:11:04 +01:00
|
|
|
#include "gui.hh"
|
2009-11-23 19:52:30 +01:00
|
|
|
#include "utils.hh"
|
|
|
|
|
|
|
|
SDL_Surface *screen;
|
|
|
|
|
|
|
|
static void run(void)
|
|
|
|
{
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
SDL_Event ev;
|
2009-11-25 19:14:48 +01:00
|
|
|
|
|
|
|
while (SDL_PollEvent(&ev)) {
|
2009-11-23 19:52:30 +01:00
|
|
|
if (ev.type == SDL_QUIT)
|
2009-11-23 20:47:01 +01:00
|
|
|
exit(1);
|
2009-11-23 19:52:30 +01:00
|
|
|
|
2009-12-13 09:54:25 +01:00
|
|
|
Gui::gui->pushEvent(&ev);
|
2009-11-23 19:52:30 +01:00
|
|
|
}
|
2009-12-13 09:54:25 +01:00
|
|
|
Gui::gui->runLogic();
|
|
|
|
Gui::gui->draw(screen);
|
2009-11-23 19:52:30 +01:00
|
|
|
|
2009-11-23 20:33:51 +01:00
|
|
|
SDL_Flip(screen);
|
2009-11-23 19:52:30 +01:00
|
|
|
SDL_Delay(50);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init(void)
|
|
|
|
{
|
|
|
|
screen = SDL_SetVideoMode(640, 480, 16,
|
|
|
|
SDL_DOUBLEBUF);
|
|
|
|
panic_if(!screen, "Cannot initialize video: %s\n", SDL_GetError());
|
|
|
|
TTF_Init();
|
|
|
|
|
2009-12-13 09:54:25 +01:00
|
|
|
Gui::init();
|
|
|
|
Gui::gui->activate();
|
2009-11-23 19:52:30 +01:00
|
|
|
}
|
2009-11-19 18:59:43 +01:00
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2009-11-23 19:52:30 +01:00
|
|
|
init();
|
|
|
|
run();
|
2009-11-19 18:59:43 +01:00
|
|
|
return 0;
|
|
|
|
}
|