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
User prompt
The bubbles seems to intersect with the barriers more than once, please update the code such that it only triggers if the bubble is moving towards each specific barrier
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
Bubbles should intersect barriers, and bounce based on circle to line intersection. With each barrier being considered four lines and each bubble being a circle. The balls should bounce of the barriers similar to how the logic would be implemented in billiard or eight ball pool. Please consider that both bubbles and barriers have their anchor set at .5,.5
User prompt
Bubbles should intersect barriers, and bounce based on circle to line intersection. With each barrier being considered four lines and each bubble being a circle. The balls should bounce of the barriers similar to how the logic would be implemented in billiard or eight ball pool. Please consider that both bubbles and barriers have their anchor set at .5,.5
Code edit (1 edits merged)
Please save this source code
User prompt
Bubbles should intersect barriers, and bounce based on circle to line intersection. With each barrier being considered four lines. The balls should bounce of the barriers similar to how the logic would be implemented in billiard or eight ball pool.
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: checkLineIntersection' in or related to this line: 'if (checkLineIntersection(self.x, self.y, self.x + speedX, self.y + speedY, line.x1, line.y1, line.x2, line.y2) && movingTowards) {' Line Number: 85
User prompt
Please fix the bug: 'TypeError: self.intersectsLine is not a function. (In 'self.intersectsLine(line.x1, line.y1, line.x2, line.y2)', 'self.intersectsLine' is undefined)' in or related to this line: 'if (self.intersectsLine(line.x1, line.y1, line.x2, line.y2) && movingTowards) {' Line Number: 85
Code edit (1 edits merged)
Please save this source code
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. Consider the barriers 4 lines each that is intersected with individually. With the circles new speedX and speedY being calculated based on circle to line intersections using real physics.
User prompt
n ball update, update the intersection logic such that it's between the ball circle and the barrier rectangle. With all the faces of the rectangle being factored in. Please factor in that both barrier and balls have an anchor point of .5, .5
===================================================================
--- 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: 0
+ anchorY: .5
});
});
var Bubble = Container.expand(function (max_types) {
var self = Container.call(this);
@@ -69,9 +69,9 @@
y2: barrier.y - barrier.height / 2
}];
for (var j = 0; j < lines.length; j++) {
var line = lines[j];
- var intersections = circleLineIntersection({
+ var intersections = circleLineSegmentIntersection({
x: self.x,
y: self.y,
radius: self.width / 2
}, line);
@@ -239,30 +239,35 @@
* Game Code
****/
// Method to calculate the intersection between a circle and a line
//Game size 2048x2732
-function circleLineIntersection(circle, line) {
- var dx = line.x2 - line.x1;
- var dy = line.y2 - line.y1;
- var dr = Math.sqrt(dx * dx + dy * dy);
- var D = line.x1 * line.y2 - line.x2 * line.y1;
- var discriminant = circle.radius * circle.radius * dr * dr - D * D;
- if (discriminant < 0) {
- // No intersection
- return [];
+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 {
- // Intersection(s)
- var intersections = [{
- x: (D * dy + Math.sign(dy) * dx * Math.sqrt(discriminant)) / (dr * dr),
- y: (-D * dx + Math.abs(dy) * Math.sqrt(discriminant)) / (dr * dr)
- }];
- if (discriminant > 0) {
- intersections.push({
- x: (D * dy - Math.sign(dy) * dx * Math.sqrt(discriminant)) / (dr * dr),
- y: (-D * dx - Math.abs(dy) * Math.sqrt(discriminant)) / (dr * dr)
- });
- }
- return intersections;
+ // 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;
@@ -271,5 +276,34 @@
var barrier = game.addChild(new Barrier());
barrier.y = 2732 - 500;
barrier.x = 2048 / 5 * a + 2048 / 5;
barriers.push(barrier);
-}
\ No newline at end of file
+}
+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
+ }];
+ console.log(circleLineSegmentIntersection({
+ x: x,
+ y: y,
+ radius: 20
+ }, lines[1]));
+};
\ 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.