summary refs log tree commit diff stats
path: root/mazeoflife.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mazeoflife.cpp')
-rw-r--r--mazeoflife.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/mazeoflife.cpp b/mazeoflife.cpp index ba5faa9..0dbca55 100644 --- a/mazeoflife.cpp +++ b/mazeoflife.cpp
@@ -7,8 +7,7 @@ int main(int argc, char *argv[])
7{ 7{
8 srand(time(NULL)); 8 srand(time(NULL));
9 9
10 /* Initialize defaults, Video and Audio */ 10 if((SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER)==-1)) {
11 if((SDL_Init(SDL_INIT_VIDEO)==-1)) {
12 printf("Could not initialize SDL: %s.\n", SDL_GetError()); 11 printf("Could not initialize SDL: %s.\n", SDL_GetError());
13 exit(-1); 12 exit(-1);
14 } 13 }
@@ -36,11 +35,11 @@ int main(int argc, char *argv[])
36 35
37 state = new TitleState(); 36 state = new TitleState();
38 37
38 SDL_AddTimer(TICKDELAY, *tick, NULL);
39
39 SDL_Event anEvent; 40 SDL_Event anEvent;
40 for (;;) 41 for (;;)
41 { 42 {
42 state->tick();
43
44 while (SDL_PollEvent(&anEvent)) 43 while (SDL_PollEvent(&anEvent))
45 { 44 {
46 switch (anEvent.type) 45 switch (anEvent.type)
@@ -90,3 +89,10 @@ void changeState(State* nState)
90{ 89{
91 state = nState; 90 state = nState;
92} 91}
92
93Uint32 tick(Uint32 interval, void *param)
94{
95 state->tick();
96
97 return interval;
98}