diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-07-23 05:47:43 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-07-23 05:47:43 (GMT) |
commit | 5054fafde6b32003c8c00877f2579c611d1524f3 (patch) | |
tree | 9f79976f970095706e82d7d65b068c1e7b728d97 /demos/declarative/samegame/content/samegame.js | |
parent | dd652f37353a01e0172e20f1e7ef24b001a281db (diff) | |
parent | dc68651b60b552e010735903e45328f8ebf18f69 (diff) | |
download | Qt-5054fafde6b32003c8c00877f2579c611d1524f3.zip Qt-5054fafde6b32003c8c00877f2579c611d1524f3.tar.gz Qt-5054fafde6b32003c8c00877f2579c611d1524f3.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'demos/declarative/samegame/content/samegame.js')
-rw-r--r-- | demos/declarative/samegame/content/samegame.js | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index b1b2c50..6bcfd17 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -50,10 +50,8 @@ var fillFound; var floodBoard; var lastHoveredIdx = -2 -function handleHover(x,y, btn) +function handleHover(xIdx,yIdx, btn) { - xIdx = Math.floor(x/tileSize); - yIdx = Math.floor(y/tileSize); if(index(xIdx, yIdx) == lastHoveredIdx) return; lastHoveredIdx = index(xIdx, yIdx); @@ -67,11 +65,9 @@ function handleHover(x,y, btn) //Could use the fillFound value to tell the player how many stones/points } -function handleClick(x,y) +function handleClick(xIdx,yIdx) { //NOTE: Be careful with vars named x,y - they can set to the calling object - xIdx = Math.floor(x/tileSize); - yIdx = Math.floor(y/tileSize); if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) return; if(board[index(xIdx, yIdx)] == null) @@ -166,9 +162,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 +175,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 +188,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? |