commit 6d6b2788
The setAIlevel method is now private
Changed files
| M | source/code/BlockGame.cpp before |
| M | source/code/BlockGame.hpp before |
| M | source/code/main.cpp before |
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp
index 156f5a0..27bc5e8 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -310,6 +310,7 @@ void BlockGame::NewGame(const BlockGameStartInfo &s) {
}
else {
name = "CPU";
+ setAIlevel(s.level);
}
putStartBlocks();
}
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index 2deeb7d..e261f53 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -158,9 +158,6 @@ public:
void setGameSpeed(int globalSpeedLevel);
void setHandicap(int globalHandicap);
- //Set the move speed of the AI based on the aiLevel parameter
- //Also enables AI
- void setAIlevel(int aiLevel);
int getAIlevel() const;
virtual void AddText(int x, int y, const std::string& text, int time) const {}
@@ -292,7 +289,9 @@ private:
///////////////////////////// AI ends here! //////////////////////////////
////////
//////////////////////////////////////////////////////////////////
-
+ //Set the move speed of the AI based on the aiLevel parameter
+ //Also enables AI
+ void setAIlevel(int aiLevel);
void PushLineInternal();
//Updates evrything, if not called nothing happends
void Update();
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 148ad4a..7a4a5ce 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -1525,26 +1525,26 @@ static void StarTwoPlayerTimeTrial() {
BlockGameStartInfo startInfo;
startInfo.ticks = SDL_GetTicks();
startInfo.timeTrial = true;
- player1->NewGame(startInfo);
- player2->NewGame(startInfo);
- int theTime = time(0);
- player1->putStartBlocks(theTime);
- player2->putStartBlocks(theTime);
- twoPlayers = true;
- player1->setGameSpeed(player1Speed);
- player2->setGameSpeed(player2Speed);
- player1->setHandicap(player1handicap);
- player2->setHandicap(player2handicap);
+ BlockGameStartInfo startInfo2 = startInfo;
registerTTHighscorePlayer1 = true;
registerTTHighscorePlayer2 = true;
if (player1AI) {
- player1->setAIlevel(player1AIlevel);
+ startInfo.AI = true;
+ startInfo.level = player1AIlevel;
registerTTHighscorePlayer1 = false;
}
if (player2AI) {
- player2->setAIlevel(player2AIlevel);
+ startInfo2.AI = true;
+ startInfo2.level = player2AIlevel;
registerTTHighscorePlayer2 = false;
}
+ player1->NewGame(startInfo);
+ player2->NewGame(startInfo2);
+ twoPlayers = true;
+ player1->setGameSpeed(player1Speed);
+ player2->setGameSpeed(player2Speed);
+ player1->setHandicap(player1handicap);
+ player2->setHandicap(player2handicap);
player1->name = player1name;
player2->name = player2name;
}
@@ -1554,9 +1554,18 @@ static void StartTwoPlayerVs() {
BlockGameStartInfo startInfo;
startInfo.ticks = SDL_GetTicks();
startInfo.vsMode = true;
+ BlockGameStartInfo startInfo2 = startInfo;
+ if (player1AI) {
+ startInfo.AI = true;
+ startInfo.level = player1AIlevel;
+ }
+ if (player2AI) {
+ startInfo2.AI = true;
+ startInfo2.level = player2AIlevel;
+ }
player1->NewGame(startInfo);
player1->setGarbageTarget(player2);
- player2->NewGame(startInfo);
+ player2->NewGame(startInfo2);
player2->setGarbageTarget(player1);
//vsMode = true;
twoPlayers = true;
@@ -1564,12 +1573,6 @@ static void StartTwoPlayerVs() {
player2->setGameSpeed(player2Speed);
player1->setHandicap(player1handicap);
player2->setHandicap(player2handicap);
- if (player1AI) {
- player1->setAIlevel(player1AIlevel);
- }
- if (player2AI) {
- player2->setAIlevel(player2AIlevel);
- }
int theTime = time(0);
player1->putStartBlocks(theTime);
player2->putStartBlocks(theTime);
@@ -1577,7 +1580,6 @@ static void StartTwoPlayerVs() {
player2->name = player2name;
}
-//The main function, quite big... too big
//Warning: the arguments to main must be "int argc, char* argv[]" NO CONST! or SDL_main will fail to find it
int main(int argc, char* argv[]) {
try {
@@ -1988,14 +1990,12 @@ int runGame(int gametype, int level) {
startInfo.vsMode = true;
theGame.NewGame(startInfo);
theGame.setGarbageTarget(&theGame2);
+ startInfo.AI = true;
+ startInfo.level = theAIlevel;
theGame2.NewGame(startInfo);
theGame2.setGarbageTarget(&theGame);
DrawIMG(backgroundImage, screen, 0, 0);
twoPlayers = true; //Single player, but AI plays
- theGame2.setAIlevel((Uint8)theAIlevel);
- int theTime = time(0);
- theGame.putStartBlocks(theTime);
- theGame2.putStartBlocks(theTime);
theGame.name = player1name;
theGame2.name = player2name;
}