diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-06-18 16:24:02 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2009-06-18 16:24:02 -0400 |
commit | 10ccc825777c7ce8797fc58e1484dd93f19368cf (patch) | |
tree | 75333f5f5abc653a621e442129613fd4fdade8c1 /mazeoflife.cpp | |
download | mazeoflife-10ccc825777c7ce8797fc58e1484dd93f19368cf.tar.gz mazeoflife-10ccc825777c7ce8797fc58e1484dd93f19368cf.tar.bz2 mazeoflife-10ccc825777c7ce8797fc58e1484dd93f19368cf.zip |
Created base
Diffstat (limited to 'mazeoflife.cpp')
-rw-r--r-- | mazeoflife.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/mazeoflife.cpp b/mazeoflife.cpp new file mode 100644 index 0000000..0e3464a --- /dev/null +++ b/mazeoflife.cpp | |||
@@ -0,0 +1,58 @@ | |||
1 | #include "includes.h" | ||
2 | |||
3 | bool gameSleep = false; | ||
4 | |||
5 | int main(int argc, char *argv[]) | ||
6 | { | ||
7 | /* Initialize defaults, Video and Audio */ | ||
8 | if((SDL_Init(SDL_INIT_VIDEO)==-1)) { | ||
9 | printf("Could not initialize SDL: %s.\n", SDL_GetError()); | ||
10 | exit(-1); | ||
11 | } | ||
12 | |||
13 | /* Clean up on exit */ | ||
14 | atexit(SDL_Quit); | ||
15 | |||
16 | /* | ||
17 | * Initialize the display in a 640x480 8-bit palettized mode, | ||
18 | * requesting a software surface | ||
19 | */ | ||
20 | SDL_Surface *screen = SDL_SetVideoMode(WIDTH*16, HEIGHT*16, 8, SDL_DOUBLEBUF); | ||
21 | if ( screen == NULL ) { | ||
22 | fprintf(stderr, "Couldn't set %dx%dx8 video mode: %s\n", WIDTH*16, WIDTH*16, SDL_GetError()); | ||
23 | exit(1); | ||
24 | } | ||
25 | |||
26 | SDL_WM_SetCaption("Maze Of Life", NULL); | ||
27 | |||
28 | State* state = new GameState(screen->format); | ||
29 | |||
30 | SDL_Event anEvent; | ||
31 | for (;;) | ||
32 | { | ||
33 | while (SDL_PollEvent(&anEvent)) | ||
34 | { | ||
35 | switch (anEvent.type) | ||
36 | { | ||
37 | case SDL_ACTIVEEVENT: | ||
38 | if (anEvent.active.state == SDL_APPINPUTFOCUS) | ||
39 | { | ||
40 | // gameSleep = !anEvent.active.gain; | ||
41 | } | ||
42 | |||
43 | break; | ||
44 | case SDL_QUIT: | ||
45 | exit(0); | ||
46 | |||
47 | break; | ||
48 | } | ||
49 | } | ||
50 | |||
51 | state->render(screen); | ||
52 | |||
53 | SDL_Flip(screen); | ||
54 | } | ||
55 | |||
56 | exit(0); | ||
57 | } | ||
58 | |||