Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: null is not an object (evaluating 'bubbleIndex.row')' in or related to this line: 'if (rows[bubbleIndex.row].length == 12) {' Line Number: 211
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: 'TypeError: null is not an object (evaluating 'bubbleIndex.row')' in or related to this line: 'if (rows[bubbleIndex.row].length == 12) {' Line Number: 211
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: intersectedBubble' in or related to this line: 'var intersectedBubblePos = self.findBubbleIndex(intersectedBubble);' Line Number: 313
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: 'ReferenceError: Can't find variable: isActive' in or related to this line: 'if (isActive) {' Line Number: 57
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
before calling showGameOver flash screen white
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (23 edits merged)
Please save this source code
User prompt
implement //Loop over rows, if a row only has empty values in it, remove it.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'game.addChildAt(currentBubble, particleInjectionZIndex);' Line Number: 555
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -221,12 +221,12 @@
};
self.printRowsToConsole = function () {
var gridString = '';
for (var i = rows.length - 1; i >= 0; i--) {
- var rowString = '' + i + ': ';
+ var rowString = ': ' + (rows[i].length == 13 ? '' : ' ');
for (var j = 0; j < rows[i].length; j++) {
var bubble = rows[i][j];
- rowString += bubble ? '[' + bubble.type + ']' : '[ ]';
+ rowString += bubble ? '[' + bubble.type + ']' : '[_]';
}
gridString += rowString + '\n';
}
console.log(gridString);
@@ -245,9 +245,9 @@
}
var dx = nextX - bubble.x - self.x;
var dy = nextY - bubble.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < (bubble.width - 10) / 2 + bubble.width / 2) {
+ if (distance < (bubble.width - 50) / 2 + bubble.width / 2) {
return bubble;
}
}
}
@@ -293,89 +293,105 @@
angle: angle
});
};
self.update = function () {
- for (var a = 0; a < bubblesInFlight.length; a++) {
- var current = bubblesInFlight[a];
- var bubble = current.bubble;
- var nextX = bubble.x + Math.cos(current.angle) * 20;
- var nextY = bubble.y + Math.sin(current.angle) * 20;
- if (nextX < 150 / 2 || nextX > 2048 - 150 / 2) {
- current.angle = Math.PI - current.angle; // Reflect angle
- nextX = Math.min(Math.max(nextX, 150 / 2), 2048 - 150 / 2);
- // bubble.x = currentPoint.x + stepSize * Math.cos(radians); // Recalculate nextX after reflection
- }
- var intersectedBubble = self.bubbleIntersectsGrid(nextX + self.x, nextY + self.y);
- if (intersectedBubble) {
- var intersectedBubblePos = self.findBubbleRowAndColumn(intersectedBubble);
- var colOffset = rows[intersectedBubblePos.row].length == 13 ? 3 : 2;
- var offsetPositions = [{
- x: intersectedBubble.x - intersectedBubble.width / 2,
- y: intersectedBubble.y - 1.7320508076 * intersectedBubble.height / 2,
- ro: intersectedBubblePos.row + 1,
- co: intersectedBubblePos.col - 1 + colOffset
- }, {
- x: intersectedBubble.x + intersectedBubble.width / 2,
- y: intersectedBubble.y - 1.7320508076 * intersectedBubble.height / 2,
- ro: intersectedBubblePos.row + 1,
- co: intersectedBubblePos.col + colOffset
- }, {
- x: intersectedBubble.x + intersectedBubble.width,
- y: intersectedBubble.y,
- ro: intersectedBubblePos.row,
- co: intersectedBubblePos.col + 1
- }, {
- x: intersectedBubble.x + intersectedBubble.width / 2,
- y: intersectedBubble.y + 1.7320508076 * intersectedBubble.height / 2,
- ro: intersectedBubblePos.row - 1,
- co: intersectedBubblePos.col - 1 + colOffset
- }, {
- x: intersectedBubble.x - intersectedBubble.width / 2,
- y: intersectedBubble.y + 1.7320508076 * intersectedBubble.height / 2,
- ro: intersectedBubblePos.row - 1,
- co: intersectedBubblePos.col + colOffset
- }, {
- x: intersectedBubble.x - intersectedBubble.width,
- y: intersectedBubble.y,
- ro: intersectedBubblePos.row,
- co: intersectedBubblePos.col - 1
- }];
- var closestPosition = 0;
- var closestDistance = Math.sqrt(Math.pow(offsetPositions[0].x - bubble.x, 2) + Math.pow(offsetPositions[0].y - bubble.y, 2));
- for (var i = 1; i < offsetPositions.length; i++) {
- var currentPosition = offsetPositions[i];
- var currentDistance = Math.sqrt(Math.pow(currentPosition.x - bubble.x, 2) + Math.pow(currentPosition.y - bubble.y, 2));
- if (currentDistance < closestDistance) {
- var row = rows[currentPosition.ro];
- if (row) {
- if (row[currentPosition.co]) {
+ for (var rep = 0; rep < 3; rep++) {
+ for (var a = 0; a < bubblesInFlight.length; a++) {
+ var current = bubblesInFlight[a];
+ var bubble = current.bubble;
+ var nextX = bubble.x + Math.cos(current.angle) * 20;
+ var nextY = bubble.y + Math.sin(current.angle) * 20;
+ if (nextX < 150 / 2 || nextX > 2048 - 150 / 2) {
+ current.angle = Math.PI - current.angle; // Reflect angle
+ nextX = Math.min(Math.max(nextX, 150 / 2), 2048 - 150 / 2);
+ }
+ var intersectedBubble = self.bubbleIntersectsGrid(nextX + self.x, nextY + self.y);
+ if (intersectedBubble) {
+ var intersectedBubblePos = self.findBubbleRowAndColumn(intersectedBubble);
+ var colOffset = rows[intersectedBubblePos.row].length == 13 ? 0 : 1;
+ var offsetPositions = [{
+ x: intersectedBubble.x - intersectedBubble.width / 2,
+ y: intersectedBubble.y - 1.7320508076 * intersectedBubble.height / 2,
+ ro: intersectedBubblePos.row + 1,
+ co: intersectedBubblePos.col - 1 + colOffset
+ }, {
+ x: intersectedBubble.x + intersectedBubble.width / 2,
+ y: intersectedBubble.y - 1.7320508076 * intersectedBubble.height / 2,
+ ro: intersectedBubblePos.row + 1,
+ co: intersectedBubblePos.col + colOffset
+ }, {
+ x: intersectedBubble.x + intersectedBubble.width,
+ y: intersectedBubble.y,
+ ro: intersectedBubblePos.row,
+ co: intersectedBubblePos.col + 1
+ }, {
+ x: intersectedBubble.x + intersectedBubble.width / 2,
+ y: intersectedBubble.y + 1.7320508076 * intersectedBubble.height / 2,
+ ro: intersectedBubblePos.row - 1,
+ co: intersectedBubblePos.col + colOffset
+ }, {
+ x: intersectedBubble.x - intersectedBubble.width / 2,
+ y: intersectedBubble.y + 1.7320508076 * intersectedBubble.height / 2,
+ ro: intersectedBubblePos.row - 1,
+ co: intersectedBubblePos.col - 1 + colOffset
+ }, {
+ x: intersectedBubble.x - intersectedBubble.width,
+ y: intersectedBubble.y,
+ ro: intersectedBubblePos.row,
+ co: intersectedBubblePos.col - 1
+ }];
+ var closestPosition = 0;
+ var closestDistance = Math.sqrt(Math.pow(offsetPositions[0].x - bubble.x, 2) + Math.pow(offsetPositions[0].y - bubble.y, 2));
+ for (var i = 1; i < offsetPositions.length; i++) {
+ var currentPosition = offsetPositions[i];
+ var currentDistance = Math.sqrt(Math.pow(currentPosition.x - bubble.x, 2) + Math.pow(currentPosition.y - bubble.y, 2));
+ if (currentDistance < closestDistance) {
+ var row = rows[currentPosition.ro];
+ if (currentPosition.co < 0) {
continue;
}
+ if (row) {
+ if (row[currentPosition.co]) {
+ continue;
+ }
+ if (currentPosition.co >= row.length) {
+ console.log("rejected");
+ continue;
+ }
+ } else {
+ var newRowLength = rows[intersectedBubblePos.row].length == 13 ? 12 : 13;
+ if (currentPosition.co >= newRowLength) {
+ console.log("Length rejected for new row");
+ continue;
+ }
+ }
+ closestDistance = currentDistance;
+ closestPosition = i;
}
- closestDistance = currentDistance;
- closestPosition = i;
}
- }
- console.log(offsetPositions[closestPosition]);
- // Attach bubble to the closest position
- bubble.x = offsetPositions[closestPosition].x;
- bubble.y = offsetPositions[closestPosition].y;
- var row = rows[offsetPositions[closestPosition].ro];
- if (!row) {
- if (rows[intersectedBubblePos.row].length == 13) {
- row = [null, null, null, null, null, null, null, null, null, null, null, null];
- } else {
- row = [null, null, null, null, null, null, null, null, null, null, null, null, null];
+ console.log(offsetPositions[closestPosition]);
+ // Attach bubble to the closest position
+ bubble.x = offsetPositions[closestPosition].x;
+ bubble.y = offsetPositions[closestPosition].y;
+ var row = rows[offsetPositions[closestPosition].ro];
+ if (!row) {
+ if (rows[intersectedBubblePos.row].length == 13) {
+ row = [null, null, null, null, null, null, null, null, null, null, null, null];
+ } else {
+ row = [null, null, null, null, null, null, null, null, null, null, null, null, null];
+ }
+ rows.unshift(row);
}
- rows.unshift(row);
+ console.log(offsetPositions[closestPosition].co);
+ row[offsetPositions[closestPosition].co] = bubble;
+ console.log(row);
+ bubblesInFlight.splice(a--, 1);
+ self.printRowsToConsole();
+ refreshHintLine();
+ } else {
+ bubble.x = nextX;
+ bubble.y = nextY;
}
- row[currentPosition.co] = bubble;
- console.log(row);
- bubblesInFlight.splice(a--, 1);
- self.printRowsToConsole();
- } else {
- bubble.x = nextX;
- bubble.y = nextY;
}
}
};
insertRow();
@@ -509,21 +525,28 @@
var hintBubbles = [];
var isValid = false;
var path = [];
var bubbleAlpha = 1;
+var hintTargetX = 0;
+var hintTargetY = 0;
game.move = function (x, y, obj) {
- var ox = x - launcher.x;
- var oy = y - launcher.y;
+ hintTargetX = x;
+ hintTargetY = y;
+ refreshHintLine();
+ // }
+};
+function refreshHintLine() {
+ var ox = hintTargetX - launcher.x;
+ var oy = hintTargetY - launcher.y;
var angle = Math.atan2(oy, ox);
launcher.angle = angle;
isValid = angle < -.2 && angle > -Math.PI + .2;
if (isValid) {
path = grid.calculatePath(launcher, angle);
//This allows updated faster than 60fps, making everyting feel better.
renderHintBubbels();
}
- // }
-};
+}
var hintOffset = 0;
var distanceBetweenHintbubbles = 100;
function renderHintBubbels() {
if (game.children.length < particleInjectionZIndex) {
@@ -568,9 +591,9 @@
}
}
}
game.update = function () {
- hintOffset += 3;
+ hintOffset += 5;
if (isValid) {
bubbleAlpha = Math.min(bubbleAlpha + .05, 1);
} else {
bubbleAlpha = Math.max(bubbleAlpha - .05, 0);
Circular white gradient circle on black background. Gradient from white on the center to black on the outer edge all around.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Soft straight Long red paint on black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Fire ball. Bubble shooter game. Thin black outline.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
green notification bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.