From 150a240098c3b45799ff04411715866b9dc58f4f Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 19 Jun 2009 22:46:29 -0400 Subject: Fixed solver wrapping issue Previously, the generated mazes didn't wrap and it would be very difficult to wrap. This has been fixed. Plus, titles have been added to all states and the "gameSleep" variable has been removed due to it's not-usefulness. --- gamestate.cpp | 36 +++++++++++++++++------------------- htpstate.cpp | 2 ++ mazeoflife.cpp | 8 -------- titlestate.cpp | 2 ++ 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/gamestate.cpp b/gamestate.cpp index 39d589d..c312bfe 100644 --- a/gamestate.cpp +++ b/gamestate.cpp @@ -39,15 +39,7 @@ void GameState::input(SDLKey key) break; case SDLK_ESCAPE: - newGame = false; - - info.playerx = 1; - info.playery = 1; - info.level = Level(); - info.doneMaking = false; - board = Board(&info); - - SDL_WM_SetCaption("Maze Of Life - Level 1", NULL); + changeState(new TitleState()); break; } @@ -241,14 +233,14 @@ void GameState::Board::tick() int neighbors = 0; - if ((x>0)&&(y>0)) incrementIfNeighbor(x-1,y-1,temp,&neighbors); - if ((x>0)) incrementIfNeighbor(x-1,y,temp,&neighbors); - if ((x>0)&&(y0)) incrementIfNeighbor(x,y-1,temp,&neighbors); - if ((y0)) incrementIfNeighbor(x+1,y-1,temp,&neighbors); - if ((xplayerx==x)&&(info->playery==y))||((x==15)&&(y==15))) + if (!((nx!=x)&&(ny!=y))) { - ++*tick; + if ((temp[x][y])||((info->playerx==x)&&(info->playery==y))||((x==15)&&(y==15))) + { + ++*tick; + } } } diff --git a/htpstate.cpp b/htpstate.cpp index 273392e..ad830da 100644 --- a/htpstate.cpp +++ b/htpstate.cpp @@ -7,6 +7,8 @@ HowToPlayState::HowToPlayState() pointer = SDL_LoadBMP("pointer.bmp"); secondPage = false; selection = 0; + + SDL_WM_SetCaption("Maze Of Life - How To Play", NULL); } void HowToPlayState::input(SDLKey key) diff --git a/mazeoflife.cpp b/mazeoflife.cpp index e962f2e..4ec9250 100644 --- a/mazeoflife.cpp +++ b/mazeoflife.cpp @@ -1,7 +1,6 @@ #include "includes.h" SDL_Surface *screen; -bool gameSleep = false; State* state; int main(int argc, char *argv[]) @@ -42,13 +41,6 @@ int main(int argc, char *argv[]) { switch (anEvent.type) { - case SDL_ACTIVEEVENT: - if (anEvent.active.state == SDL_APPINPUTFOCUS) - { - gameSleep = !anEvent.active.gain; - } - - break; case SDL_QUIT: exit(0); diff --git a/titlestate.cpp b/titlestate.cpp index 144148a..425e4ca 100644 --- a/titlestate.cpp +++ b/titlestate.cpp @@ -5,6 +5,8 @@ TitleState::TitleState() background = SDL_LoadBMP("title.bmp"); pointer = SDL_LoadBMP("pointer.bmp"); selection = 0; + + SDL_WM_SetCaption("Maze Of Life", NULL); } void TitleState::input(SDLKey key) -- cgit 1.4.1