diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-01 08:52:53 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-10-05 02:39:06 (GMT) |
commit | 02a248c9c57714d4ad1ba775d9e60a7f286f10c6 (patch) | |
tree | 743fabc6335dcef88cbf8a4400a9181edba9293e /demos | |
parent | 361a605e9269f3072c1f5597a8db0622cf3b116b (diff) | |
download | Qt-02a248c9c57714d4ad1ba775d9e60a7f286f10c6.zip Qt-02a248c9c57714d4ad1ba775d9e60a7f286f10c6.tar.gz Qt-02a248c9c57714d4ad1ba775d9e60a7f286f10c6.tar.bz2 |
Prevent writes to the global object
Also add toString() method to qobjects
Diffstat (limited to 'demos')
-rwxr-xr-x | demos/declarative/samegame/content/samegame.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 4a9179b..09057eb 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -24,7 +24,7 @@ function timeStr(msecs) { function initBoard() { - for(i = 0; i<maxIndex; i++){ + for(var i = 0; i<maxIndex; i++){ //Delete old blocks if(board[i] != null) board[i].destroy(); @@ -42,8 +42,8 @@ function initBoard() //Initialize Board board = new Array(maxIndex); gameCanvas.score = 0; - for(xIdx=0; xIdx<maxX; xIdx++){ - for(yIdx=0; yIdx<maxY; yIdx++){ + for(var xIdx=0; xIdx<maxX; xIdx++){ + for(var yIdx=0; yIdx<maxY; yIdx++){ board[index(xIdx,yIdx)] = null; createBlock(xIdx,yIdx); } @@ -58,8 +58,8 @@ var floodBoard;//Set to 1 if the floodFill reaches off that node //NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope function handleClick(x,y) { - xIdx = Math.floor(x/tileSize); - yIdx = Math.floor(y/tileSize); + var xIdx = Math.floor(x/tileSize); + var yIdx = Math.floor(y/tileSize); if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0) return; if(board[index(xIdx, yIdx)] == null) @@ -105,14 +105,14 @@ function floodFill(xIdx,yIdx,type) function shuffleDown() { //Fall down - for(xIdx=0; xIdx<maxX; xIdx++){ - fallDist = 0; - for(yIdx=maxY-1; yIdx>=0; yIdx--){ + for(var xIdx=0; xIdx<maxX; xIdx++){ + 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.targetY += fallDist * tileSize; board[index(xIdx,yIdx+fallDist)] = obj; board[index(xIdx,yIdx)] = null; @@ -143,8 +143,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) @@ -166,7 +166,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) || @@ -174,7 +174,7 @@ function floodMoveCheck(xIdx, yIdx, type) } function createBlock(xIdx,yIdx){ - if(component==null) + if(component==null) component = createComponent(tileSrc); // Note that we don't wait for the component to become ready. This will @@ -182,7 +182,7 @@ function createBlock(xIdx,yIdx){ // not be ready immediately. There is a statusChanged signal on the // component you could use if you want to wait to load remote files. if(component.isReady){ - dynamicObject = component.createObject(); + var dynamicObject = component.createObject(); if(dynamicObject == null){ print("error creating block"); print(component.errorsString()); |