+bool GameBoard::UndoLastMove(int & dx, int & dy, int & type)
+{
+ if (numMoves == 0)
+ return false;
+
+ numMoves--;
+ dx = undo[numMoves].dx;
+ dy = undo[numMoves].dy;
+ type = undo[numMoves].type;
+
+ // Undo the box's move (if any)
+ if (type == PMPush)
+ {
+ int boxPosition = (playerX + dx) + ((playerY + dy) * width);
+ int newBoxPosition = playerX + (playerY * width);
+
+ board[boxPosition] &= GTBoxSpot;
+// board[newBoxPosition] &= GTBoxSpot; // This is extraneous
+ board[newBoxPosition] |= GTBox;
+ }
+
+ // Undo the player's move
+ playerX += -dx;
+ playerY += -dy;
+
+ return true;
+}
+