Code edit (1 edits merged)
Please save this source code
User prompt
update hsv saturation to .3
User prompt
Detect if no moves are possible and show game over
User prompt
Fix Bug: 'TypeError: null is not an object (evaluating 'squares[i][j + 1].value')' in this line: 'if (j < gridSize - 1 && squares[i][j].value === squares[i][j + 1].value) {' Line Number: 124
User prompt
Fix Bug: 'TypeError: null is not an object (evaluating 'squares[i + 1][j].value')' in this line: 'if (i < gridSize - 1 && squares[i][j].value === squares[i + 1][j].value) {' Line Number: 121
User prompt
When calling game over, set scale and alpha of all tiles to 1
User prompt
for the win message use font: 'Sans-Serif' & weight: '800'
User prompt
Set the win condition to 16 rather than 2048
Code edit (1 edits merged)
Please save this source code
User prompt
Change win message color to black with white drop shadow and size 150
Code edit (1 edits merged)
Please save this source code
User prompt
Change win message font size to 150, remove the drop shadow but add a 4px black stroke instead
Code edit (4 edits merged)
Please save this source code
User prompt
set strokeThickness on win message to 25
Code edit (1 edits merged)
Please save this source code
User prompt
Set strokeThickness on all other text2 objects than win message to 0
User prompt
Set strokeThickness on all other text2 objects than win message to 0
Code edit (1 edits merged)
Please save this source code
User prompt
Set scale and alpha on the first two tiles that spawn on board to 1
User prompt
Also update LK.setScore when updating scores
User prompt
Lk set score calls should have the same value as set value
User prompt
When updating the score text also update LK.setScore
===================================================================
--- original.js
+++ change.js
@@ -66,9 +66,8 @@
tileLabel.y = -40;
self.addChild(tileLabel);
self.setValue = function (value) {
self.newValue = value;
- LK.setScore(value);
};
self.updateToRealValue = function () {
if (self.newValue) {
self.value = self.newValue;
@@ -176,28 +175,24 @@
}
}
if (emptyPositions.length > 0) {
var randomPosition = emptyPositions[Math.floor(Math.random() * emptyPositions.length)];
- var newValue = Math.random() < 0.5 ? 2 : 4;
- var square = new Tile(newValue);
+ var square = new Tile(Math.random() < 0.5 ? 2 : 4);
square.setPosition(randomPosition.x, randomPosition.y, true);
squares[randomPosition.x][randomPosition.y] = square;
gridContainer.addChild(square);
- LK.setScore(newValue);
}
};
game.mergeTiles = function (x1, y1, x2, y2) {
if (squares[x1][y1] !== null && squares[x2][y2] !== null && squares[x1][y1].value === squares[x2][y2].value && !squares[x1][y1].merged && !squares[x2][y2].merged) {
- var newValue = squares[x2][y2].value * 2;
- squares[x2][y2].setValue(newValue, true);
+ squares[x2][y2].setValue(squares[x2][y2].value * 2, true);
squares[x2][y2].merged = true;
squares[x1][y1].targetX = squares[x2][y2].targetX;
squares[x1][y1].targetY = squares[x2][y2].targetY;
toBeRemoved.push(squares[x1][y1]);
squares[x1][y1] = null;
gridContainer.removeChild(squares[x2][y2]);
gridContainer.addChild(squares[x2][y2]);
- LK.setScore(newValue);
return true;
}
return false;
};
@@ -386,9 +381,11 @@
return Math.max.apply(Math, row.map(function (tile) {
return tile ? tile.value : 0;
}));
}));
- scoreTxt.setText(maxTileValue.toString());
+ var newScore = maxTileValue;
+ LK.setScore(newScore);
+ scoreTxt.setText(newScore.toString());
}
if (!game.checkPossibleMoves()) {
for (var i = 0; i < gridSize; i++) {
for (var j = 0; j < gridSize; j++) {