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
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'currentBubble = hintBubbles[hintBubbleOffset] = new HintBubble();' Line Number: 554
Code edit (10 edits merged)
Please save this source code
User prompt
implement self.printRowsToConsole = function () { //Prints nice representation of the rows grid to console as a string };
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (14 edits merged)
Please save this source code
User prompt
We have the pixel offsets for the bubbles around offsetPositions, however we also want to offset in terms of offset in the rows / columns grid. Can you add that as rx: and ry:
User prompt
Add row / column offsets to offsetPositions
User prompt
implement //Loop trough the offsetPositions and find the one that bubble is closest to
Code edit (4 edits merged)
Please save this source code
User prompt
implement //Calculate the position of potential neighbour bubbles into a list here
Code edit (1 edits merged)
Please save this source code
User prompt
implement /* Based on the intersectedBubble x,y position calculate the 6 points around this bubble where another bubble could exist and put that into a list. */
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
===================================================================
--- original.js
+++ change.js
@@ -27,9 +27,9 @@
max_types = max_types || 3;
self.type = Math.floor(Math.random() * max_types);
bubbleGraphics.tint = bubbleColors[self.type];
self.detach = function () {
- game.addChild(self);
+ freeBubbleLayer.addChild(self);
self.y += grid.y;
isAttached = false;
speedX = Math.random() * 40 - 20;
speedY = -Math.random() * 30;
@@ -111,21 +111,8 @@
}
rows.push(row);
rowCount++;
}
- self.findBubbleRowAndColumn = function (bubble) {
- for (var row = 0; row < rows.length; row++) {
- for (var col = 0; col < rows[row].length; col++) {
- if (rows[row][col] === bubble) {
- return {
- row: row,
- col: col
- };
- }
- }
- }
- return null; // Return null if the bubble is not found in the grid
- };
//Method that removes an array of bubbles from the rows array.
self.removeBubbles = function (bubbles) {
for (var i = 0; i < bubbles.length; i++) {
var bubble = bubbles[i];
@@ -191,9 +178,9 @@
[0, -1], [0, 1],
// above and below
[-1, -1], [1, -1] // diagonals for even rows
];
- if (bubbleIndex.row % 2 === 1) {
+ if (rows[bubbleIndex.row].length == 12) {
// Adjust diagonals for odd rows
directions[4] = [-1, 1];
directions[5] = [1, 1];
}
@@ -297,17 +284,17 @@
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;
+ var nextX = bubble.x + Math.cos(current.angle) * 35;
+ var nextY = bubble.y + Math.sin(current.angle) * 35;
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 intersectedBubblePos = self.findBubbleIndex(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,
@@ -367,9 +354,8 @@
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];
@@ -382,12 +368,24 @@
rows.unshift(row);
}
console.log(offsetPositions[closestPosition].co);
row[offsetPositions[closestPosition].co] = bubble;
- console.log(row);
bubblesInFlight.splice(a--, 1);
self.printRowsToConsole();
refreshHintLine();
+ var bubbles = self.getConnectedBubbles(bubble);
+ if (bubbles.length > 2) {
+ self.removeBubbles(bubbles);
+ var disconnected = self.getDetachedBubbles();
+ self.removeBubbles(disconnected);
+ }
+ for (var row = rows.length - 1; row >= 0; row--) {
+ if (rows[row].every(function (bubble) {
+ return bubble === null;
+ })) {
+ rows.splice(row, 1);
+ }
+ }
} else {
bubble.x = nextX;
bubble.y = nextY;
}
@@ -453,9 +451,9 @@
self.applyBubble = function (bubble) {
var scoreIndicator = game.addChild(new ScoreIndicatorLabel(baseValue, bubble.type));
scoreIndicator.x = self.x;
scoreIndicator.y = self.y;
- var particle = game.addChildAt(new BubbleRemoveParticle(), particleInjectionZIndex);
+ var particle = particlesLayer.addChild(new BubbleRemoveParticle());
particle.x = bubble.x;
particle.y = self.y + 100;
};
});
@@ -514,11 +512,13 @@
sm.y = 2300;
scoreMultipliers.push(sm);
game.addChild(sm);
}
-var particleInjectionZIndex = game.children.length;
+var particlesLayer = game.addChild(new Container());
var grid = game.addChild(new Grid());
grid.y = 1300;
+var freeBubbleLayer = game.addChild(new Container());
+var hintBubblePlayer = game.addChild(new Container());
var launcher = game.addChild(new Launcher());
launcher.x = game.width / 2;
launcher.y = game.height - 180;
var hintBubbleCache = [];
@@ -548,11 +548,8 @@
}
var hintOffset = 0;
var distanceBetweenHintbubbles = 100;
function renderHintBubbels() {
- if (game.children.length < particleInjectionZIndex) {
- return;
- }
if (isValid) {
hintOffset = hintOffset % distanceBetweenHintbubbles;
var distanceSinceLastDot = -hintOffset + 100;
var hintBubbleOffset = 0;
@@ -568,9 +565,9 @@
var angle = Math.atan2(oy, ox);
var currentBubble = hintBubbles[hintBubbleOffset];
if (!currentBubble) {
currentBubble = hintBubbles[hintBubbleOffset] = new HintBubble();
- game.addChildAt(currentBubble, particleInjectionZIndex);
+ hintBubblePlayer.addChild(currentBubble);
}
currentBubble.alpha = bubbleAlpha;
currentBubble.visible = true;
currentBubble.x = lastPoint.x - Math.cos(angle) * amountOver;
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.