commit 706e81fe
In addition to right clicking you can now also swipe from below the board to get a new line
Changed files
| M | source/code/BlockGameSdl.inc before |
| M | source/code/main.cpp before |
diff --git a/source/code/BlockGameSdl.inc b/source/code/BlockGameSdl.inc
index 54cc86b..7592e98 100644
--- a/source/code/BlockGameSdl.inc
+++ b/source/code/BlockGameSdl.inc
@@ -56,7 +56,7 @@ public:
* @param y brick y. Unchanged if outside border
*/
void GetBrickCoordinateFromMouse(bool& match, int mousex, int mousey, int& x, int& y) const {
- if (mousex < topx || mousex > topx+50*6 || mousey < topy || mousey > topy+50*12) {
+ if (!IsInTheBoard(mousex, mousey)) {
match = false;
return;
}
@@ -64,6 +64,20 @@ public:
x = (mousex-topx) / 50;
y = (50*12+topy-mousey-pixels) / 50;
}
+
+ bool IsInTheBoard(int mousex, int mousey) const {
+ if (mousex < topx || mousex > topx+50*6 || mousey < topy || mousey > topy+50*12) {
+ return false;
+ }
+ return true;
+ }
+
+ bool IsUnderTheBoard(int mousex, int mousey) const {
+ if (mousex < topx || mousex > topx+50*6 || mousey < topy+50*12) {
+ return false;
+ }
+ return true;
+ }
void AddText(int x, int y, const std::string& text, int time) const override {
theTextManager.addText(topx-10+x*bsize, topy+12*bsize-y*bsize, text, time);
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 85759cb..a936dda 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -1698,7 +1698,8 @@ int runGame(int gametype, int level) {
if (isPlayerPushEvent(1, event)) {
theGame.PushLine();
}
-
+ static int mouseDownX = 0;
+ static int mouseDownY = 0;
if (event.type == SDL_MOUSEBUTTONDOWN) {
if (event.button.button == SDL_BUTTON_LEFT) {
bool pressed = false;
@@ -1712,6 +1713,8 @@ int runGame(int gametype, int level) {
if (pressed) {
theGame2.MouseDown(x, y);
}
+ mouseDownX = event.button.x;
+ mouseDownY = event.button.y;
}
if (event.button.button == SDL_BUTTON_RIGHT) {
bool pressed = false;
@@ -1729,8 +1732,16 @@ int runGame(int gametype, int level) {
}
if (event.type == SDL_MOUSEBUTTONUP) {
if (event.button.button == SDL_BUTTON_LEFT) {
+ int x = event.button.x;
+ int y = event.button.y;
theGame.MouseUp();
theGame2.MouseUp();
+ if (theGame.IsInTheBoard(x,y) && theGame.IsUnderTheBoard(mouseDownX, mouseDownY)) {
+ theGame.PushLine();
+ }
+ if (theGame2.IsInTheBoard(x,y) && theGame2.IsUnderTheBoard(mouseDownX, mouseDownY)) {
+ theGame2.PushLine();
+ }
}
}
if (event.type == SDL_MOUSEMOTION) {