summary refs log tree commit diff stats
path: root/gamestate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gamestate.cpp')
-rw-r--r--gamestate.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/gamestate.cpp b/gamestate.cpp index 40229ba..39d589d 100644 --- a/gamestate.cpp +++ b/gamestate.cpp
@@ -10,6 +10,7 @@ GameState::GameState()
10 info.playerx = 1; 10 info.playerx = 1;
11 info.playery = 1; 11 info.playery = 1;
12 info.level = Level(); 12 info.level = Level();
13 info.doneMaking = false;
13 board = Board(&info); 14 board = Board(&info);
14 15
15 SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); 16 SDL_WM_SetCaption("Maze Of Life - Level 1", NULL);
@@ -17,35 +18,39 @@ GameState::GameState()
17 18
18void GameState::input(SDLKey key) 19void GameState::input(SDLKey key)
19{ 20{
20 switch (key) 21 if (info.doneMaking)
21 { 22 {
22 case SDLK_LEFT: 23 switch (key)
23 move(info.playerx-1, info.playery); 24 {
25 case SDLK_LEFT:
26 move(info.playerx-1, info.playery);
24 27
25 break; 28 break;
26 case SDLK_RIGHT: 29 case SDLK_RIGHT:
27 move(info.playerx+1, info.playery); 30 move(info.playerx+1, info.playery);
28 31
29 break; 32 break;
30 case SDLK_UP: 33 case SDLK_UP:
31 move(info.playerx, info.playery-1); 34 move(info.playerx, info.playery-1);
32 35
33 break; 36 break;
34 case SDLK_DOWN: 37 case SDLK_DOWN:
35 move(info.playerx, info.playery+1); 38 move(info.playerx, info.playery+1);
36 39
37 break; 40 break;
38 case SDLK_ESCAPE: 41 case SDLK_ESCAPE:
39 newGame = false; 42 newGame = false;
40 43
41 info.playerx = 1; 44 info.playerx = 1;
42 info.playery = 1; 45 info.playery = 1;
43 info.level = Level(); 46 info.level = Level();
44 board = Board(&info); 47 info.doneMaking = false;
48 board = Board(&info);
45 49
46 SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); 50 SDL_WM_SetCaption("Maze Of Life - Level 1", NULL);
47 51
48 break; 52 break;
53 }
49 } 54 }
50} 55}
51 56
@@ -62,6 +67,7 @@ void GameState::tick()
62 } 67 }
63 68
64 info.level.incrementLevel(); 69 info.level.incrementLevel();
70 info.doneMaking = false;
65 board = Board(&info); 71 board = Board(&info);
66 newGame = false; 72 newGame = false;
67 73
@@ -252,6 +258,8 @@ void GameState::Board::tick()
252 } 258 }
253 } 259 }
254 } 260 }
261
262 if (!info->doneMaking && ++gens > 100) info->doneMaking = true;
255} 263}
256 264
257void GameState::Board::incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick) 265void GameState::Board::incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick)