From 1e3808b3338ff3b1499e000ce1f23e87d6050b8c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 18 Jun 2009 21:04:49 -0400 Subject: Added the doneMaking process back Fixes #102 --- gamestate.cpp | 50 +++++++++++++++++++++++++++++--------------------- gamestate.h | 2 ++ 2 files changed, 31 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() info.playerx = 1; info.playery = 1; info.level = Level(); + info.doneMaking = false; board = Board(&info); SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); @@ -17,35 +18,39 @@ GameState::GameState() void GameState::input(SDLKey key) { - switch (key) + if (info.doneMaking) { - case SDLK_LEFT: - move(info.playerx-1, info.playery); + switch (key) + { + case SDLK_LEFT: + move(info.playerx-1, info.playery); - break; - case SDLK_RIGHT: - move(info.playerx+1, info.playery); + break; + case SDLK_RIGHT: + move(info.playerx+1, info.playery); - break; - case SDLK_UP: - move(info.playerx, info.playery-1); + break; + case SDLK_UP: + move(info.playerx, info.playery-1); - break; - case SDLK_DOWN: - move(info.playerx, info.playery+1); + break; + case SDLK_DOWN: + move(info.playerx, info.playery+1); - break; - case SDLK_ESCAPE: - newGame = false; + break; + case SDLK_ESCAPE: + newGame = false; - info.playerx = 1; - info.playery = 1; - info.level = Level(); - board = Board(&info); + info.playerx = 1; + info.playery = 1; + info.level = Level(); + info.doneMaking = false; + board = Board(&info); - SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); + SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); - break; + break; + } } } @@ -62,6 +67,7 @@ void GameState::tick() } info.level.incrementLevel(); + info.doneMaking = false; board = Board(&info); newGame = false; @@ -252,6 +258,8 @@ void GameState::Board::tick() } } } + + if (!info->doneMaking && ++gens > 100) info->doneMaking = true; } void GameState::Board::incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick) diff --git a/gamestate.h b/gamestate.h index 5537b51..7d9d798 100644 --- a/gamestate.h +++ b/gamestate.h @@ -28,6 +28,7 @@ class GameState : public State { struct Info { int playerx, playery; Level level; + bool doneMaking; }; class Board @@ -36,6 +37,7 @@ class GameState : public State { bool blocks[WIDTH][HEIGHT]; void incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick); GameState::Info* info; + int gens; public: Board(); -- cgit 1.4.1