Code edit (9 edits merged)
Please save this source code
User prompt
The score colors does not work as the format must be "#xxxxxx"
User prompt
In ScoreIndicatorLabel use the bubbleColors values to set color based on type. Make sure to covert to string hex values
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: undefined is not an object (evaluating 'scoreMultipliers[Math.floor(self.x / (2048 / 5))].applyBubble')' in or related to this line: 'scoreMultipliers[Math.floor(self.x / (2048 / 5))].applyBubble(self);' Line Number: 77
Code edit (5 edits merged)
Please save this source code
User prompt
If unattached bubbles falls below 2732 - 500 remove them
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
In ScoreMultipliers add a score label text string. This should be white with the font Impact.
Code edit (10 edits merged)
Please save this source code
User prompt
Use impact for the score label
User prompt
Add a score label to the top center of the screen. The score label should be centered and have a black outline and white font
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
when circles and barriers intersect, move the circle back, such that it just touches the barrier and no longer intersects
Code edit (1 edits merged)
Please save this source code
User prompt
Move the ball outside the barrier so they no longer intersects, when they intersect
Code edit (7 edits merged)
Please save this source code
User prompt
When intersecting a barrier, the new speed should be based on ball to ball intersection like billiard balls. With the barrier being static and the bubbles being standard billiard balls
User prompt
Bubbles should bounce on barriers, using circle to circle intersections and billiard ball like physics
Code edit (1 edits merged)
Please save this source code
User prompt
When intersection a barrier with a bubble. Move the bubble out of the barrier such that they no longer intersects
User prompt
If a ball intersects a barrier, it should be rejected out of the barrier
Code edit (11 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -4,9 +4,9 @@
var Barrier = Container.expand(function () {
var self = Container.call(this);
var barrierGraphics = self.attachAsset('barrier', {
anchorX: .5,
- anchorY: .5
+ anchorY: 0
});
});
var Bubble = Container.expand(function (max_types) {
var self = Container.call(this);
@@ -43,66 +43,19 @@
speedY += 1.5;
if (self.x < self.width / 2 && speedX < 0 || self.x > game.width - self.width / 2 && speedX > 0) {
speedX = -speedX;
}
- // Check for intersection with each barrier
+ // Check for collision with barriers
for (var i = 0; i < barriers.length; i++) {
var barrier = barriers[i];
- var lines = [{
- x1: barrier.x - barrier.width / 2,
- y1: barrier.y - barrier.height / 2,
- x2: barrier.x + barrier.width / 2,
- y2: barrier.y - barrier.height / 2
- }, {
- x1: barrier.x + barrier.width / 2,
- y1: barrier.y - barrier.height / 2,
- x2: barrier.x + barrier.width / 2,
- y2: barrier.y + barrier.height / 2
- }, {
- x1: barrier.x + barrier.width / 2,
- y1: barrier.y + barrier.height / 2,
- x2: barrier.x - barrier.width / 2,
- y2: barrier.y + barrier.height / 2
- }, {
- x1: barrier.x - barrier.width / 2,
- y1: barrier.y + barrier.height / 2,
- x2: barrier.x - barrier.width / 2,
- y2: barrier.y - barrier.height / 2
- }];
- for (var j = 0; j < lines.length; j++) {
- var line = lines[j];
- var intersects = circleLineSegmentIntersection({
- x: self.x,
- y: self.y,
- radius: self.width / 2
- }, line);
- if (intersects) {
- //isAttached = true;
- // Bounce off the barrier
- var normal = {
- x: line.y2 - line.y1,
- y: line.x1 - line.x2
- };
- var magnitude = Math.sqrt(normal.x * normal.x + normal.y * normal.y);
- normal.x /= magnitude;
- normal.y /= magnitude;
- var dot = speedX * normal.x + speedY * normal.y;
- // Only bounce if the bubble is moving towards the barrier
- if (dot < 0) {
- speedX -= 2 * dot * normal.x;
- speedY -= 2 * dot * normal.y;
- // Move the bubble out of the barrier
- while (circleLineSegmentIntersection({
- x: self.x,
- y: self.y,
- radius: self.width / 2
- }, line)) {
- self.x += normal.x;
- self.y += normal.y;
- }
- break;
- }
- }
+ var dx = self.x - barrier.x;
+ var dy = self.y - barrier.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ var minDist = self.width / 2 + barrier.width / 2;
+ if (distance < minDist) {
+ var angle = Math.atan2(dy, dx);
+ speedX = Math.cos(angle) * 10;
+ speedY = Math.sin(angle) * 10;
}
}
}
};
@@ -250,76 +203,14 @@
/****
* Game Code
****/
-// Method to calculate the intersection between a circle and a line
//Game size 2048x2732
-function circleLineSegmentIntersection(circle, lineSegment) {
- var cx = circle.x,
- cy = circle.y,
- radius = circle.radius;
- var x1 = lineSegment.x1,
- y1 = lineSegment.y1,
- x2 = lineSegment.x2,
- y2 = lineSegment.y2;
- // Calculate distances
- var dx = x2 - x1;
- var dy = y2 - y1;
- var a = dx * dx + dy * dy;
- var b = 2 * (dx * (x1 - cx) + dy * (y1 - cy));
- var c = (x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy) - radius * radius;
- var det = b * b - 4 * a * c;
- if (a <= 0.0000001 || det < 0) {
- // No real solutions, no intersection
- return false;
- } else if (det == 0) {
- // One solution, tangent line
- var t = -b / (2 * a);
- return t >= 0 && t <= 1;
- } else {
- // Two solutions, check if either are on the segment
- var t1 = (-b + Math.sqrt(det)) / (2 * a);
- var t2 = (-b - Math.sqrt(det)) / (2 * a);
- return t1 >= 0 && t1 <= 1 || t2 >= 0 && t2 <= 1;
- }
-}
var grid = game.addChild(new Grid());
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;
barriers.push(barrier);
-}
-/*var testBubble = game.addChild(new Bubble());
-game.move = function (x, y) {
- var barrier = barriers[barriers.length - 1];
- var lines = [{
- x1: barrier.x - barrier.width / 2,
- y1: barrier.y - barrier.height / 2,
- x2: barrier.x + barrier.width / 2,
- y2: barrier.y - barrier.height / 2
- }, {
- x1: barrier.x + barrier.width / 2,
- y1: barrier.y - barrier.height / 2,
- x2: barrier.x + barrier.width / 2,
- y2: barrier.y + barrier.height / 2
- }, {
- x1: barrier.x + barrier.width / 2,
- y1: barrier.y + barrier.height / 2,
- x2: barrier.x - barrier.width / 2,
- y2: barrier.y + barrier.height / 2
- }, {
- x1: barrier.x - barrier.width / 2,
- y1: barrier.y + barrier.height / 2,
- x2: barrier.x - barrier.width / 2,
- y2: barrier.y - barrier.height / 2
- }];
- testBubble.x = x;
- testBubble.y = y;
- console.log(circleLineSegmentIntersection({
- x: x,
- y: y,
- radius: 150 / 2
- }, lines[3]));
-};*/
\ No newline at end of file
+}
\ 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.