summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-07-23 05:00:45 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-07-23 05:00:45 (GMT)
commitf8dff7351ede7ec032947e8d5b6c3268485a1da5 (patch)
tree458151260c447f648ee4086587a2d6c7f879d636 /demos
parent7d94f78cf6ef86cc71e126d554267b91e4427a26 (diff)
downloadQt-f8dff7351ede7ec032947e8d5b6c3268485a1da5.zip
Qt-f8dff7351ede7ec032947e8d5b6c3268485a1da5.tar.gz
Qt-f8dff7351ede7ec032947e8d5b6c3268485a1da5.tar.bz2
SameGame should now correctly determine game over
Diffstat (limited to 'demos')
-rw-r--r--demos/declarative/samegame/content/samegame.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index b1b2c50..91d97d5 100644
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -166,9 +166,8 @@ function victoryCheck()
{
//awards bonuses
deservesBonus = true;
- for(xIdx=maxX-1; xIdx>=0; xIdx--)
- if(board[index(xIdx, maxY - 1)] != null)
- deservesBonus = false;
+ if(board[index(0, maxY - 1)] != null)
+ deservesBonus = false;
if(deservesBonus)
gameCanvas.score += 500;
//Checks for game over
@@ -180,7 +179,8 @@ function victoryCheck()
function noMoreMoves()
{
- return !floodMoveCheck(0, maxY-1, -1);
+ moreMoves = floodMoveCheck(0, maxY-1, -1);
+ return !moreMoves;
}
function floodMoveCheck(xIdx, yIdx, type)
@@ -192,7 +192,9 @@ function floodMoveCheck(xIdx, yIdx, type)
myType = board[index(xIdx, yIdx)].type;
if(type == myType)
return true;
- return floodMoveCheck(xIdx + 1, yIdx, myType) || floodMoveCheck(xIdx, yIdx - 1, myType);
+ var at = myType;
+ var bt = myType;
+ return floodMoveCheck(xIdx + 1, yIdx, at) || floodMoveCheck(xIdx, yIdx - 1, bt);
}
//Need a simpler method of doing this?