git repos / blockattack-game

commit 3e7b8813

sago007 · 2016-02-22 19:45
3e7b8813244cf165884cd2d36dbaa91b8b8eb5b0 patch · browse files
parent 7ac8aa4bbd79a320d5fce20d0df5671d31524b2f

member functions for setting speed and handicap are no longer public member functions

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 1ec7426..57e42d5 100644 --- a/source/code/BlockGame.cpp +++ b/source/code/BlockGame.cpp
@@ -318,6 +318,12 @@ void BlockGame::NewGame(const BlockGameStartInfo &s) {
if (s.startBlocks >= 0) {
putStartBlocks(s.startBlocks);
}
+ if (s.handicap > 0) {
+ setHandicap(s.handicap);
+ }
+ if (s.gameSpeed > 0) {
+ setGameSpeed(s.gameSpeed);
+ }
}
//Instead of creating new object new game is called, to prevent memory leaks
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index 5c82c67..e820cfc 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp
@@ -54,6 +54,8 @@ struct BlockGameStartInfo {
bool AI = false;
bool vsMode = false;
int startBlocks = -1;
+ int handicap = 0;
+ int gameSpeed = 0;
};
struct GarbageStruct {
@@ -137,8 +139,6 @@ public:
BlockGame();
virtual ~BlockGame();
- void setGameSpeed(int globalSpeedLevel);
- void setHandicap(int globalHandicap);
int getAIlevel() const;
virtual void AddText(int x, int y, const std::string& text, int time) const {}
@@ -170,6 +170,10 @@ public:
int GetCursorY() const;
void MoveCursorTo(int x, int y);
bool GetIsWinner() const;
+ bool isSinglePuzzle() const;
+ int getLevel() const;
+ bool GetAIenabled() const;
+ bool IsNearDeath() const;
void NewGame(const BlockGameStartInfo &s);
//Creates garbage using a given wide and height
bool CreateGarbage(int wide, int height);
@@ -177,8 +181,6 @@ public:
bool CreateGreyGarbage();
//prints "Game Over" and ends game
void SetGameOver();
- bool GetAIenabled() const;
- bool IsNearDeath() const;
//Moves the cursor, receaves N,S,E or W as a char an moves as desired
void MoveCursor(char way);
//switches the two blocks at the cursor position, unless game over
@@ -188,11 +190,8 @@ public:
void Update(unsigned int newtick);
//Prints "winner" and ends game
void setPlayerWon();
- //void SetGameOver();
//Prints "draw" and ends the game
void setDraw();
- bool isSinglePuzzle() const;
- int getLevel() const;
void setGarbageTarget(BlockGame* garbageTarget);
BlockGame* getGarbageTarget() const;
private:
@@ -207,6 +206,8 @@ private:
void putStartBlocks(int n);
//decreases hang for all hanging blocks and wait for waiting blocks
void ReduceStuff();
+ void setGameSpeed(int globalSpeedLevel);
+ void setHandicap(int globalHandicap);
//Clears garbage, must take one the lower left corner!
int GarbageClearer(int x, int y, int number, bool aLineToClear, int chain);
//Marks garbage that must be cleared
diff --git a/source/code/main.cpp b/source/code/main.cpp index 1191050..1a1cd59 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -1538,13 +1538,13 @@ static void StarTwoPlayerTimeTrial() {
startInfo2.level = player2AIlevel;
registerTTHighscorePlayer2 = false;
}
+ startInfo.gameSpeed = player1Speed;
+ startInfo2.gameSpeed = player2Speed;
+ startInfo.handicap = player1handicap;
+ startInfo2.handicap = player2handicap;
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;
}
@@ -1564,16 +1564,16 @@ static void StartTwoPlayerVs() {
startInfo2.AI = true;
startInfo2.level = player2AIlevel;
}
+ startInfo.gameSpeed = player1Speed;
+ startInfo2.gameSpeed = player2Speed;
+ startInfo.handicap = player1handicap;
+ startInfo2.handicap = player2handicap;
player1->NewGame(startInfo);
player1->setGarbageTarget(player2);
player2->NewGame(startInfo2);
player2->setGarbageTarget(player1);
//vsMode = true;
twoPlayers = true;
- player1->setGameSpeed(player1Speed);
- player2->setGameSpeed(player2Speed);
- player1->setHandicap(player1handicap);
- player2->setHandicap(player2handicap);
player1->name = player1name;
player2->name = player2name;
}