aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/avalanche/nim.cpp55
-rw-r--r--engines/avalanche/nim.h4
2 files changed, 28 insertions, 31 deletions
diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp
index 6ea719fd4f..2a1dd5ec48 100644
--- a/engines/avalanche/nim.cpp
+++ b/engines/avalanche/nim.cpp
@@ -47,8 +47,6 @@ void Nim::resetVariables() {
_row = 0;
_number = 0;
_squeak = false;
- _mNum = 0;
- _mRow = 0;
_lmo = false;
for (int i = 0; i < 3; i++) {
@@ -223,32 +221,35 @@ void Nim::blip() {
_vm->_sound->playNote(1771, 3);
}
-bool Nim::checkMouse() {
- Common::Point cursorPos = _vm->getMousePos();
- _vm->_graphics->refreshScreen();
- Common::Event event;
- // This loop needs "some" revision!!!
- while (_vm->getEvent(event)) {
+bool Nim::checkInput() {
+ while (!_vm->shouldQuit()) {
_vm->_graphics->refreshScreen();
- if (event.type == Common::EVENT_LBUTTONUP) {
- _mRow = (cursorPos.y / 2 - 38) / 35 - 1;
- if ((_mRow < 0) || (_mRow > 2)) {
- blip();
- return false;
- }
- _mNum = _stones[_mRow] - ((cursorPos.x - 64) / 64);
- if ((_mNum < 1) || (_mNum > _stones[_mRow])) {
- blip();
- return false;
+ Common::Event event;
+ while (_vm->getEvent(event)) {
+ if (event.type == Common::EVENT_LBUTTONUP) {
+ Common::Point cursorPos = _vm->getMousePos();
+
+ int8 mRow = (cursorPos.y / 2 - 38) / 35 - 1;
+ if ((mRow < 0) || (mRow > 2)) {
+ blip();
+ return false;
+ }
+
+ int8 mNum = _stones[mRow] - ((cursorPos.x - 64) / 64);
+ if ((mNum < 1) || (mNum > _stones[mRow])) {
+ blip();
+ return false;
+ }
+
+ _number = mNum;
+ _row = mRow;
+
+ return true;
}
- return true;
}
}
-}
-void Nim::less() {
- if (_number > 1)
- _number--;
+
}
void Nim::takeSome() {
@@ -272,16 +273,14 @@ void Nim::takeSome() {
_vm->_graphics->drawRectangle(Common::Rect(63 + (sr - _number) * 64, 38 + 35 * (_row + 1), 54 + sr * 64, 63 + 35 * (_row + 1)), kColorBlue);
_vm->_graphics->refreshScreen();
- bool clicked = false;
+ bool validInput = false;
do {
- clicked = checkMouse();
- } while (clicked == false);
+ validInput = checkInput();
+ } while (!validInput);
_vm->_graphics->drawRectangle(Common::Rect(63 + (sr - _number) * 64, 38 + 35 * (_row + 1), 54 + sr * 64, 63 + 35 * (_row + 1)), kColorBlack);
_vm->_graphics->refreshScreen();
- _number = _mNum;
- _row = _mRow;
return;
} while (true);
diff --git a/engines/avalanche/nim.h b/engines/avalanche/nim.h
index 6afb915e47..79787373cb 100644
--- a/engines/avalanche/nim.h
+++ b/engines/avalanche/nim.h
@@ -51,7 +51,6 @@ private:
byte _row;
byte _number;
bool _squeak;
- int8 _mNum, _mRow;
byte _playedNim; // How many times you've played Nim.
// Inner variables for dogFood(), find() and findAp().
@@ -65,8 +64,7 @@ private:
void startMove();
void showChanges();
void blip();
- bool checkMouse();
- void less();
+ bool checkInput();
void takeSome();
void endOfGame();
bool find(byte x); // This gives TRUE if there's a pile with x stones in.