Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting '3')' in or related to this line: 'currentLevel[self.gridY][self.gridX] = self.colorIndex;' Line Number: 189
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < a.length; i++) {' Line Number: 357
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < a.length; i++) {' Line Number: 357
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < a.length; i++) {' Line Number: 357
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting '5')' in or related to this line: 'currentLevel[self.gridY][self.gridX] = self.colorIndex;' Line Number: 189
Code edit (13 edits merged)
Please save this source code
User prompt
Please fix the bug: 'newPosition is not defined' in or related to this line: 'if (newPosition != 999) {' Line Number: 638
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'levelContainer.children.findAll is not a function' in or related to this line: 'var outliers = levelContainer.children.findAll(function (child) {' Line Number: 548
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'boxspacing is not defined' in or related to this line: 'b.y = offset + startY + i * (boxSize + boxspacing); // determine this' Line Number: 448
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'cBox is not defined' in or related to this line: 'cBox.width = cBox.height = tileSize;' Line Number: 428
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (13 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Set is not a constructor' in or related to this line: 'return n;' Line Number: 176
===================================================================
--- original.js
+++ change.js
@@ -315,9 +315,9 @@
var numRunningTweens = 0; // input is blocked while tweens running, so increment this when a tween starts, nd decrement when tween ends.
var outlierDirectionCounter = 0; //0; // increment to allow outliers spawning on different side each turn.
var playerScore = 0;
var colors = ['0x000000', '0xffffff', '0xffff00'];
-var gridSize = 7;
+var gridSize = 5;
var spacingRatio = 0.2;
var boardSize = 1300;
function calculateTileSize() {
// Example of getting desired tileSize depending on gridSize (for different size grids)
@@ -334,9 +334,10 @@
var l1 = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 2, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]];
var l2 = [[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 2, 2, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 2, 2, 0, 0], [0, 0, 0, 0, 0, 0]];
var l3 = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 2, 2, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0], [0, 0, 2, 2, 0, 0, 0], [0, 2, 2, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]];
var levels = [l1, l2, l3];
-var currentLevel = levels[2].slice(0); //copy without reference, so we have original for retry/level reset.
+var currentLevelID = 0;
+var currentLevel = levels[currentLevelID].slice(0); //copy without reference, so we have original for retry/level reset.
var levelContainer = new Container();
levelContainer.x = 1024;
levelContainer.y = 2732 / 2;
game.addChild(levelContainer);
@@ -465,11 +466,12 @@
}
}
// If no available rows or cols left, level cleared!
var n = availableRows.length + availableCols.length;
- console.log(n);
+ //console.log(n);
if (n === 0) {
console.log('level cleared. TODO: write level cleared function.');
+ return false;
} else {
var startX = -boardSize / 2;
var startY = -boardSize / 2;
var boxSize = tileSize;
@@ -540,9 +542,10 @@
}
}
}
// And place them. (Animate them in from sides.)
- console.log(tween);
+ //console.log(tween);
+ return true;
}
function shuffleArray(arr) {
var j, x, index;
for (index = arr.length - 1; index > 0; index--) {
@@ -627,9 +630,13 @@
t.gridY = newPos;
//t.moveInPosition();
}
console.log(t, 'would move to position', newPos);
- if (newPos != 999) {
+ if (newPos == -1) {
+ // Game Over, lost
+ LK.setScore(playerScore);
+ LK.showGameOver();
+ } else if (newPos != 999) {
t.moveInPosition();
} else {
t.fadeOut(); // TODO: Maybe replace this with a flyout animation instead.
}
@@ -641,8 +648,9 @@
// 0: Waiting for input
// 1: Removing tiles
// 2: Moving outliers in
// 3: Generating new outliers.
+// 4: level cleared
game.update = function () {
if (GAME_STATE == -1) {
if (numRunningTweens == 0) {
GAME_STATE = 0;
@@ -660,17 +668,35 @@
}
} else if (GAME_STATE == 2) {
// moving outliers in
if (numRunningTweens == 0) {
- placeOutliers();
- GAME_STATE = 3;
+ if (placeOutliers()) {
+ GAME_STATE = 3;
+ } else {
+ GAME_STATE = 4;
+ }
}
} else if (GAME_STATE == 3) {
// generating new outliers
if (numRunningTweens == 0) {
GAME_IS_CLICKABLE = true;
GAME_STATE = 0;
}
+ } else if (GAME_STATE == 4) {
+ // go to next level or game completed.
+ // If we haven't run out of levels, fo to the next one.
+ if (currentLevelID != levels.length - 1) {
+ currentLevelID++;
+ currentLevel = levels[currentLevelID].slice(0);
+ gridSize = currentLevel.length;
+ tileSize = calculateTileSize();
+ board = new Board();
+ paintLevel();
+ placeOutliers();
+ GAME_STATE = -1;
+ } else {
+ //TODO: Show game over - all levels completed!
+ }
}
/*
if (LK.ticks % 12 == 0) {
//console.log(numRunningTweens);
A large calm background drawing for a puzzle game, in dark calm blueish colors and non-confusing content. High definition. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A quadratic polished dark blue marble slate. Front perspective with right angles. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A white question mark in a circle, like for a help button in a game.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A white X in a circle, like for a close window button in a game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A white questionmark on a black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A green check mark on a dark background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.