Skip to content

Commit

Permalink
Make normal difficulty the default choice, don't give resume game cho…
Browse files Browse the repository at this point in the history
…ice when going to menu if game is over.

git-svn-id: file:///Users/tkieft/code/SVN/snake/trunk@68 2d1a4ccd-f515-0410-a99d-d1a2ee3908d6
  • Loading branch information
tkieft committed Apr 22, 2007
1 parent 76989d0 commit 73680dd
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 10 deletions.
9 changes: 9 additions & 0 deletions Snake/Menu.cpp
Expand Up @@ -50,6 +50,15 @@ void Menu::addOptionChoice( string optName, string choice ) {
options[opt]->addChoice( choice );
}

void Menu::setDefaultChoice( string optName, string choice ) {
int opt = -1;

while( options[ ++opt ]->getName() != optName );

while( options[opt]->getCurrentChoice() != choice )
options[opt]->nextChoice();
}

void Menu::nextOption() {
if( ++currentOption >= numOptions )
currentOption = 0;
Expand Down
1 change: 1 addition & 0 deletions Snake/Menu.h
Expand Up @@ -49,6 +49,7 @@ class Menu {
void addOption( string newOption );
void addSelectableOption( string newOption );
void addOptionChoice( string optName, string choice );
void setDefaultChoice( string optName, string choice );
void nextOption();
void nextChoice();
void previousOption();
Expand Down
7 changes: 6 additions & 1 deletion Snake/SMenuState.cpp
Expand Up @@ -54,6 +54,11 @@ void SMenuState::init_menus( SGameEngine* game ) {
num_players_menu->addOptionChoice( "Difficulty", "Easy" );
num_players_menu->addOptionChoice( "Difficulty", "Normal" );
num_players_menu->addOptionChoice( "Difficulty", "Expert" );
num_players_menu->setDefaultChoice( "Difficulty", "Normal" );
//num_players_menu->addOption( "Snake 1 Name" );
//num_players_menu->addOptionChoice( "Snake 1 Name", "Tyler" );
//num_players_menu->addOption( "Snake 2 Name" );
//num_players_menu->addOptionChoice( "Snake 2 Name", "Brandon" );
num_players_menu->addSelectableOption( "Play" );
num_players_menu->addSelectableOption( "Cancel" );

Expand Down Expand Up @@ -140,7 +145,7 @@ void SMenuState::HandleEvents( SGameEngine* game )
game->ChangeState( SPlayState::Instance() );
}
}
else {
else if( current_menu == options_menu ) {
if( current_menu->getOption() == "Cancel" )
{
main_menu->reset();
Expand Down
2 changes: 1 addition & 1 deletion Snake/SPlayState.cpp
Expand Up @@ -115,7 +115,6 @@ void SPlayState::HandleEvents( SGameEngine* game )
break;
}
if( gameState == GAME_LOST ) {
game->stopPlaying();
game->ChangeState( SMenuState::Instance() );
break;
}
Expand Down Expand Up @@ -158,6 +157,7 @@ void SPlayState::Update( SGameEngine* game )
{
if( !(theSnakes[ result - 1 ]->die()) ) {
gameState = GAME_LOST;
game->stopPlaying();
theTimer.stop();
}
else {
Expand Down
89 changes: 83 additions & 6 deletions Snake/Snake.xcodeproj/tkieft.pbxuser
Expand Up @@ -185,7 +185,7 @@
hitCount = 1;
lineNumber = 252;
location = Snake;
modificationTime = 198886387.631138;
modificationTime = 198953574.995781;
state = 1;
};
0660BCE60A4A1A720007D282 /* SIntroState.h */ = {
Expand Down Expand Up @@ -229,7 +229,7 @@
hitCount = 1;
lineNumber = 50;
location = Snake;
modificationTime = 198896655.133477;
modificationTime = 198953574.995852;
state = 2;
};
06C1C4B10AFC1A5D00430E18 /* SGameEngine.cpp:43 */ = {
Expand All @@ -243,7 +243,7 @@
functionName = "SGameEngine::Init()";
hitCount = 1;
lineNumber = 43;
modificationTime = 198886387.631169;
modificationTime = 198953574.996006;
state = 2;
};
06C1C4B40AFC1A7500430E18 /* SGameEngine.cpp:26 */ = {
Expand All @@ -258,7 +258,7 @@
hitCount = 1;
lineNumber = 26;
location = Snake;
modificationTime = 198886387.631185;
modificationTime = 198953574.996083;
state = 1;
};
06C9711B0A445C4C00ECB735 /* SGameEngine.h */ = {
Expand Down Expand Up @@ -528,6 +528,76 @@
vrLen = 112;
vrLoc = 1275;
};
06D789FE0BDAED01005505FB /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 06C9711B0A445C4C00ECB735 /* SGameEngine.h */;
name = "SGameEngine.h: gameDifficulty";
rLen = 0;
rLoc = 1355;
rType = 0;
vrLen = 112;
vrLoc = 1275;
};
06D78A020BDAEDA6005505FB /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 06C9711B0A445C4C00ECB735 /* SGameEngine.h */;
name = "SGameEngine.h: gameDifficulty";
rLen = 0;
rLoc = 1355;
rType = 0;
vrLen = 112;
vrLoc = 1275;
};
06D78A0B0BDAEE5F005505FB /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 06C9711B0A445C4C00ECB735 /* SGameEngine.h */;
name = "SGameEngine.h: gameDifficulty";
rLen = 0;
rLoc = 1355;
rType = 0;
vrLen = 112;
vrLoc = 1275;
};
06D78A0F0BDAEE65005505FB /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 06C9711B0A445C4C00ECB735 /* SGameEngine.h */;
name = "SGameEngine.h: gameDifficulty";
rLen = 0;
rLoc = 1355;
rType = 0;
vrLen = 112;
vrLoc = 1275;
};
06D78A160BDBAC10005505FB /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 06C9711B0A445C4C00ECB735 /* SGameEngine.h */;
name = "SGameEngine.h: gameDifficulty";
rLen = 0;
rLoc = 1355;
rType = 0;
vrLen = 112;
vrLoc = 1275;
};
06D78A2C0BDBCA8F005505FB /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 06C9711B0A445C4C00ECB735 /* SGameEngine.h */;
name = "SGameEngine.h: gameDifficulty";
rLen = 0;
rLoc = 1355;
rType = 0;
vrLen = 112;
vrLoc = 1275;
};
06D78A2D0BDBCA92005505FB /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = 06C9711B0A445C4C00ECB735 /* SGameEngine.h */;
name = "SGameEngine.h: gameDifficulty";
rLen = 0;
rLoc = 1355;
rType = 0;
vrLen = 112;
vrLoc = 1275;
};
06FB5AEF0A47675800D6B6A4 /* Timer.h */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {554, 910}}";
Expand Down Expand Up @@ -556,7 +626,7 @@
hitCount = 1;
lineNumber = 39;
location = Snake;
modificationTime = 198886387.630967;
modificationTime = 198953574.995589;
state = 1;
};
06FB5C300A47865B00D6B6A4 /* Timer.cpp:97 */ = {
Expand All @@ -571,7 +641,7 @@
hitCount = 1;
lineNumber = 97;
location = Snake;
modificationTime = 198886387.631058;
modificationTime = 198953574.995644;
state = 1;
};
06FFD1780A3E2196003850BF /* load_image.h */ = {
Expand Down Expand Up @@ -794,6 +864,13 @@
06D789FA0BDAEC69005505FB /* PBXBookmark */ = 06D789FA0BDAEC69005505FB /* PBXBookmark */;
06D789FB0BDAEC69005505FB /* PBXTextBookmark */ = 06D789FB0BDAEC69005505FB /* PBXTextBookmark */;
06D789FC0BDAEC69005505FB /* PBXTextBookmark */ = 06D789FC0BDAEC69005505FB /* PBXTextBookmark */;
06D789FE0BDAED01005505FB /* PBXTextBookmark */ = 06D789FE0BDAED01005505FB /* PBXTextBookmark */;
06D78A020BDAEDA6005505FB /* PBXTextBookmark */ = 06D78A020BDAEDA6005505FB /* PBXTextBookmark */;
06D78A0B0BDAEE5F005505FB /* PBXTextBookmark */ = 06D78A0B0BDAEE5F005505FB /* PBXTextBookmark */;
06D78A0F0BDAEE65005505FB /* PBXTextBookmark */ = 06D78A0F0BDAEE65005505FB /* PBXTextBookmark */;
06D78A160BDBAC10005505FB /* PBXTextBookmark */ = 06D78A160BDBAC10005505FB /* PBXTextBookmark */;
06D78A2C0BDBCA8F005505FB /* PBXTextBookmark */ = 06D78A2C0BDBCA8F005505FB /* PBXTextBookmark */;
06D78A2D0BDBCA92005505FB /* PBXTextBookmark */ = 06D78A2D0BDBCA92005505FB /* PBXTextBookmark */;
};
sourceControlManager = 063E7B720A3C84C9005C4507 /* Source Control */;
userBuildSettings = {
Expand Down
4 changes: 2 additions & 2 deletions Snake/levels.txt
Expand Up @@ -293,7 +293,7 @@ A2A2A2
FFFFFF
000000

2:
1:
South Pole
Antarctica
fell through an iceberg!
Expand Down Expand Up @@ -336,7 +336,7 @@ fell through an iceberg!
FF8000
DDDDDD

1:
2:
Atlantis
???
was attacked by a merman!
Expand Down

0 comments on commit 73680dd

Please sign in to comment.