User prompt
in bubble update, if not attached, if a bubble intersects with a barrier and the bubble is moving towards the barrier. Bounce the bubble off the barrier
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 (5 edits merged)
Please save this source code
User prompt
rewrite getDetachedBubbles such that it counts from the last element in rows not the first
Code edit (5 edits merged)
Please save this source code
User prompt
in getDetachedBubbles you are using getConnectedBubbles however that is type dependent, for this case any type should count as connected.
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'if (bubble !== null && !visited.has(bubble)) {' Line Number: 105
User prompt
In var visited = new Set(connectedToTop.filter(function (bubble) { return bubble != null; })); LK does not support Set, please fix this
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return bubble !== null;' Line Number: 99
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return bubble !== undefined;' Line Number: 99
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'var visited = new Set(connectedToTop);' Line Number: 98
Code edit (1 edits merged)
Please save this source code
User prompt
Implement this //Get a list of bubbles that are not connected to the top row, or to a chain of bubbles connected to the top row. self.getDetachedBubbles = function () {}; Note that all unconnected bubbles must be detected
User prompt
getDetachedBubbles does not seem to detect all unconnected bubbles, please fix this
Code edit (5 edits merged)
Please save this source code
User prompt
Implement this //Get a list of bubbles that are not connected to the top row, or to a chain of bubbles connected to the top row. self.getDetachedBubbles = function () {}; Note that all unconnected bubbles must be detected
Code edit (4 edits merged)
Please save this source code
User prompt
Write this method //Method that gets all bubbles which are not, or do not have a recursive neighbour that is connected to the top row of bubblels self.getDetachedBubbles = function () {};
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'if (neighbor.type === bubble.type) {' Line Number: 74
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'self.removeBubbles(bubbels);' Line Number: 45
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,14 @@
/****
* Classes
****/
+var Barrier = Container.expand(function () {
+ var self = Container.call(this);
+ var barrierGraphics = self.attachAsset('barrier', {
+ anchorX: .5,
+ anchorY: 0
+ });
+});
var Bubble = Container.expand(function (max_types) {
var self = Container.call(this);
var colors = [0xff0000, 0x00ff00, 0x0000ff, 0xff00ff, 0xffff00, 0x00ffff, 0xffffff];
var bubbleGraphics = self.attachAsset('bubble', {
@@ -25,23 +32,30 @@
game.addChild(self);
self.y += grid.y;
isAttached = false;
speedX = Math.random() * 40 - 20;
- speedY = -Math.random() * 25;
+ speedY = -Math.random() * 30;
self.down = undefined;
- self.alpha = .5;
- self.interactiable = false;
};
self.update = function () {
if (!isAttached) {
self.x += speedX;
self.y += speedY;
- speedY += 1;
+ speedY += 1.5;
if (self.x < self.width / 2 && speedX < 0 || self.x > game.width - self.width / 2 && speedX > 0) {
speedX = -speedX;
}
- if (Math.random() > .8) {
- isAttached = true;
+ // Check if the bubble intersects with a barrier and is moving towards the barrier
+ for (var i = 0; i < barriers.length; i++) {
+ var barrier = barriers[i];
+ if (self.intersects(barrier)) {
+ if (self.x < barrier.x && speedX > 0 || self.x > barrier.x && speedX < 0) {
+ speedX = -speedX;
+ }
+ if (self.y < barrier.y && speedY > 0 || self.y > barrier.y && speedY < 0) {
+ speedY = -speedY;
+ }
+ }
}
}
};
});
@@ -190,5 +204,11 @@
* Game Code
****/
//Game size 2048x2732
var grid = game.addChild(new Grid());
-grid.y = 1300;
\ No newline at end of file
+grid.y = 1300;
+var barriers = [];
+for (var a = 0; a < 4; a++) {
+ var barrier = game.addChild(new Barrier());
+ barrier.y = 2732 - 500;
+ barrier.x = 2048 / 5 * a + 2048 / 5;
+}
\ No newline at end of file
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.