commit e5a23912
Gave the direction parameter a better name
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 846c44c..24c097f 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -1802,7 +1802,7 @@ void BlockGame::DoAction (const BlockGameAction& action) {
PushLine();
}
if (action.action == BlockGameAction::Action::MOVE) {
- char direction = action.value1;
+ char direction = action.way;
MoveCursor(direction);
}
if (action.action == BlockGameAction::Action::SWITCH) {
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index 53565ee..16bf2ce 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -81,8 +81,8 @@ struct GarbageStruct {
struct BlockGameAction {
enum class Action {NONE, UPDATE, SET_DRAW, SET_WON, SET_GAME_OVER, MOVE, SWITCH, PUSH};
Action action = Action::NONE;
- unsigned int tick = 0;
- int value1 = 0;
+ unsigned int tick = 0; //< Used for update
+ char way = '\0'; //< The direction to move the cursor: 'N', 'E', 'S' or 'W'
};
////////////////////////////////////////////////////////////////////////////////
@@ -181,6 +181,7 @@ public:
virtual void TimeTrialEndEvent() const {}
virtual void EndlessHighscoreEvent() const {}
+ void NewGame(const BlockGameStartInfo &s);
void DoAction (const BlockGameAction& action);
int GetScore() const;
@@ -210,7 +211,6 @@ public:
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);
//Creates garbage using a given wide and height
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 7526e52..4412f77 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -1647,22 +1647,22 @@ int runGame(int gametype, int level) {
//player1:
if ( event.key.keysym.sym == keySettings[player1keys].up ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'N';
+ a.way = 'N';
theGame.DoAction(a);
}
if ( event.key.keysym.sym == keySettings[player1keys].down ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'S';
+ a.way = 'S';
theGame.DoAction(a);
}
if ( (event.key.keysym.sym == keySettings[player1keys].left) ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'W';
+ a.way = 'W';
theGame.DoAction(a);
}
if ( (event.key.keysym.sym == keySettings[player1keys].right) ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'E';
+ a.way = 'E';
theGame.DoAction(a);
}
if ( event.key.keysym.sym == keySettings[player1keys].push ) {
@@ -1678,22 +1678,22 @@ int runGame(int gametype, int level) {
//player2:
if ( event.key.keysym.sym == keySettings[player2keys].up ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'N';
+ a.way = 'N';
theGame2.DoAction(a);
}
if ( event.key.keysym.sym == keySettings[player2keys].down ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'S';
+ a.way = 'S';
theGame2.DoAction(a);
}
if ( (event.key.keysym.sym == keySettings[player2keys].left) ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'W';
+ a.way = 'W';
theGame2.DoAction(a);
}
if ( (event.key.keysym.sym == keySettings[player2keys].right) ) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'E';
+ a.way = 'E';
theGame2.DoAction(a);
}
if ( event.key.keysym.sym == keySettings[player2keys].push ) {
@@ -1736,22 +1736,22 @@ int runGame(int gametype, int level) {
if (isPlayerUpEvent(1, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'N';
+ a.way = 'N';
theGame.DoAction(a);
}
if (isPlayerDownEvent(1, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'S';
+ a.way = 'S';
theGame.DoAction(a);
}
if (isPlayerLeftEvent(1, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'W';
+ a.way = 'W';
theGame.DoAction(a);
}
if (isPlayerRightEvent (1, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'E';
+ a.way = 'E';
theGame.DoAction(a);
}
if (isPlayerSwitchEvent(1, event)) {
@@ -1764,22 +1764,22 @@ int runGame(int gametype, int level) {
}
if (isPlayerUpEvent(2, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'N';
+ a.way = 'N';
theGame2.DoAction(a);
}
if (isPlayerDownEvent(2, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'S';
+ a.way = 'S';
theGame2.DoAction(a);
}
if (isPlayerLeftEvent(2, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'W';
+ a.way = 'W';
theGame2.DoAction(a);
}
if (isPlayerRightEvent (2, event)) {
a.action = BlockGameAction::Action::MOVE;
- a.value1 = 'E';
+ a.way = 'E';
theGame2.DoAction(a);
}
if (isPlayerSwitchEvent(2, event)) {