Code edit (1 edits merged)
Please save this source code
User prompt
implement //Based on intersectedBubblePos calculate the absolute row and column numbers to insert the current moving bubble to attach it to the grid
Code edit (3 edits merged)
Please save this source code
User prompt
fix any spelling errors in the source code
Code edit (3 edits merged)
Please save this source code
User prompt
implement self.findBubbleRowAndColumn = function (bubble) {};
Code edit (1 edits merged)
Please save this source code
User prompt
implement //Calculate the offset from the intersectedBubble to insert the bubble. Use angular math to determine the row / colum offset of where to insert the bubble.
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: this.calculateInsertionPoint is not a function. (In 'this.calculateInsertionPoint(intersectedBubble, bubble)', 'this.calculateInsertionPoint' is undefined)' in or related to this line: 'var insertionPoint = this.calculateInsertionPoint(intersectedBubble, bubble);' Line Number: 293
User prompt
implement //We have a bubble we just intersected with. We want to know where to insert this bubble into the grid. Use the intersectedBubble position in the grid as the starting point for this calculation.
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'currentBubble = hintBubbles[hintBubbleOffset] = new HintBubble();' Line Number: 463
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
implement //Calculate position that the bubble would snap into if it was part of the grid.
Code edit (20 edits merged)
Please save this source code
User prompt
Find //Calculate position that the bubble would snap into if it was part of the grid. and implement that
Code edit (1 edits merged)
Please save this source code
Code edit (20 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'bobble.y += launcher.y - self.y;' Line Number: 275
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: 'Script error.' in or related to this line: 'var dist = bubble.y - nextYx - self.x;' Line Number: 243
===================================================================
--- original.js
+++ change.js
@@ -207,8 +207,29 @@
return null;
};
// Method to calculate path of movement based on angle and starting point
//TODO: MAKE THIS MUCH FASTER!
+ self.bubbleIntersectsGrid = function (nextX, nextY) {
+ outer: for (var row = 0; row < rows.length; row++) {
+ for (var col = 0; col < rows[row].length; col++) {
+ var bubble = rows[row][col];
+ if (bubble) {
+ var dist = nextY - bubble.y - self.y;
+ //Quick exit if we are nowhere near the row
+ if (dist > 145 || dist < -145) {
+ continue outer;
+ }
+ var dx = nextX - bubble.x - self.x;
+ var dy = nextY - bubble.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 70 + bubble.width / 2) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ };
self.calculatePath = function (startPoint, angle) {
var path = [];
var currentPoint = {
x: startPoint.x,
@@ -225,31 +246,9 @@
if (nextX < 150 / 2 || nextX > 2048 - 150 / 2) {
radians = Math.PI - radians; // Reflect angle
nextX = currentPoint.x + stepSize * Math.cos(radians); // Recalculate nextX after reflection
}
- // Check for bubble collisions
- outer: for (var row = 0; row < rows.length; row++) {
- for (var col = 0; col < rows[row].length; col++) {
- var bubble = rows[row][col];
- if (bubble) {
- var dist = nextY - bubble.y - self.y;
- //Quick exit if we are nowhere near the row
- if (dist > 145 || dist < -145) {
- continue outer;
- }
- var dx = nextX - bubble.x - self.x;
- var dy = nextY - bubble.y - self.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < 70 + bubble.width / 2) {
- hitBubble = true;
- break;
- }
- }
- }
- if (hitBubble) {
- break;
- }
- }
+ hitBubble = self.bubbleIntersectsGrid(nextX, nextY);
// Add point to path and update currentPoint
path.push({
x: nextX,
y: nextY
@@ -264,16 +263,48 @@
self.addChild(bubble);
bubble.x = launcher.x;
bubble.y += launcher.y - self.y;
bubblesInFlight.push({
- bubble: bubblesInFlight,
+ bubble: bubble,
angle: angle
});
};
self.update = function () {
for (var a = 0; a < bubblesInFlight.length; a++) {
- var currentBubble = bubblesInFlight[a];
- currentBubble.bubble.x++;
+ 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 || nextY > 2048 - 150 / 2) {
+ current.angle = Math.PI - current.angle; // Reflect angle
+ // bubble.x = currentPoint.x + stepSize * Math.cos(radians); // Recalculate nextX after reflection
+ }
+ if (self.bubbleIntersectsGrid(nextX + self.x, nextY + self.y)) {
+ var closestRow = Math.round((nextY - self.y) / (1.7320508076 * bubble.width / 2));
+ var rowWidth = closestRow % 2 == 0 ? 13 : 12;
+ var closestCol = Math.round((nextX - self.x - (2048 - bubble.width * rowWidth) / 2) / bubble.width);
+ // Adjust for even/odd rows
+ if (closestRow % 2 == 0 && closestCol >= rowWidth) {
+ closestCol = rowWidth - 1;
+ } else if (closestRow % 2 != 0 && closestCol > rowWidth) {
+ closestCol = rowWidth;
+ }
+ // Ensure the column is within bounds
+ closestCol = Math.max(0, Math.min(closestCol, rowWidth - 1));
+ // Calculate the exact position
+ bubble.x = (2048 - bubble.width * rowWidth) / 2 + bubble.width * closestCol + bubble.width / 2 + self.x;
+ bubble.y = closestRow * (1.7320508076 * bubble.width / 2) + self.y;
+ // Attach the bubble to the grid
+ if (!rows[closestRow]) {
+ rows[closestRow] = [];
+ }
+ rows[closestRow][closestCol] = bubble;
+ bubble.isAttached = true;
+ bubblesInFlight.splice(a, 1); // Remove the bubble from bubblesInFlight array
+ } else {
+ bubble.x = nextX;
+ bubble.y = nextY;
+ }
}
};
insertRow();
insertRow();
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.