summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-11-10 03:14:52 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-11-10 03:35:01 (GMT)
commitca9f7764982b90bb316ccca55dbd57edc5b40d4f (patch)
tree66ccf7f5564325f31a46a89daa4a4829b4d82cc8 /examples/declarative
parent8d930f43d6e0827ece00b61676b736421b50f290 (diff)
downloadQt-ca9f7764982b90bb316ccca55dbd57edc5b40d4f.zip
Qt-ca9f7764982b90bb316ccca55dbd57edc5b40d4f.tar.gz
Qt-ca9f7764982b90bb316ccca55dbd57edc5b40d4f.tar.bz2
Fix samegame tutorial 3
the js file hadn't been updated to avoid global vars Also updating a missed particles element
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js
index 528a73c..38efb3b 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js
@@ -75,8 +75,8 @@ var floodBoard;//Set to 1 if the floodFill reaches off that node
//![1]
function handleClick(x,y)
{
- xIdx = Math.floor(x/gameCanvas.tileSize);
- yIdx = Math.floor(y/gameCanvas.tileSize);
+ var xIdx = Math.floor(x/gameCanvas.tileSize);
+ var yIdx = Math.floor(y/gameCanvas.tileSize);
if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
return;
if(board[index(xIdx, yIdx)] == null)
@@ -124,13 +124,13 @@ function shuffleDown()
{
//Fall down
for(var xIdx=0; xIdx<maxX; xIdx++){
- fallDist = 0;
- for(yIdx=maxY-1; yIdx>=0; yIdx--){
+ var fallDist = 0;
+ for(var yIdx=maxY-1; yIdx>=0; yIdx--){
if(board[index(xIdx,yIdx)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- obj = board[index(xIdx,yIdx)];
+ var obj = board[index(xIdx,yIdx)];
obj.y += fallDist * gameCanvas.tileSize;
board[index(xIdx,yIdx+fallDist)] = obj;
board[index(xIdx,yIdx)] = null;
@@ -139,14 +139,14 @@ function shuffleDown()
}
}
//Fall to the left
- fallDist = 0;
- for(xIdx=0; xIdx<maxX; xIdx++){
+ var fallDist = 0;
+ for(var xIdx=0; xIdx<maxX; xIdx++){
if(board[index(xIdx, maxY - 1)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- for(yIdx=0; yIdx<maxY; yIdx++){
- obj = board[index(xIdx,yIdx)];
+ for(var yIdx=0; yIdx<maxY; yIdx++){
+ var obj = board[index(xIdx,yIdx)];
if(obj == null)
continue;
obj.x -= fallDist * gameCanvas.tileSize;
@@ -162,8 +162,8 @@ function shuffleDown()
function victoryCheck()
{
//awards bonuses for no tiles left
- deservesBonus = true;
- for(xIdx=maxX-1; xIdx>=0; xIdx--)
+ var deservesBonus = true;
+ for(var xIdx=maxX-1; xIdx>=0; xIdx--)
if(board[index(xIdx, maxY - 1)] != null)
deservesBonus = false;
if(deservesBonus)
@@ -181,7 +181,7 @@ function floodMoveCheck(xIdx, yIdx, type)
return false;
if(board[index(xIdx, yIdx)] == null)
return false;
- myType = board[index(xIdx, yIdx)].type;
+ var myType = board[index(xIdx, yIdx)].type;
if(type == myType)
return true;
return floodMoveCheck(xIdx + 1, yIdx, myType) ||