Code edit (25 edits merged)
Please save this source code
Code edit (17 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
Code edit (3 edits merged)
Please save this source code
User prompt
in bible update, update the intersection logic to assume the barriers is a rectangle and the balls is a circle
User prompt
the modification of speedX and speedY should be based on rectangle to circle intersection and the out angle after intersection should be calculated accordingly
User prompt
In 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.
Code edit (1 edits merged)
Please save this source code
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
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.
Code edit (1 edits merged)
Please save this source code
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
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
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 (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 (10 edits merged)
Please save this source code
Code edit (25 edits merged)
Please save this source code
Code edit (4 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
User prompt
If a ball intersects a barrier, it should be rejected out of the barrier
User prompt
When intersection a barrier with a bubble. Move the bubble out of the barrier such that they no longer intersects
===================================================================
--- original.js
+++ change.js
@@ -7,8 +7,9 @@
anchorX: .5,
anchorY: 0
});
});
+// Function to check if two lines intersect
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', {
@@ -233,9 +234,39 @@
/****
* Game Code
****/
+// Function to check if two lines intersect
//Game size 2048x2732
+function checkLineIntersection(line1StartX, line1StartY, line1EndX, line1EndY, line2StartX, line2StartY, line2EndX, line2EndY) {
+ var denominator, a, b, numerator1, numerator2;
+ var result = {
+ x: null,
+ y: null,
+ onLine1: false,
+ onLine2: false
+ };
+ denominator = (line2EndY - line2StartY) * (line1EndX - line1StartX) - (line2EndX - line2StartX) * (line1EndY - line1StartY);
+ if (denominator == 0) {
+ return result;
+ }
+ a = line1StartY - line2StartY;
+ b = line1StartX - line2StartX;
+ numerator1 = (line2EndX - line2StartX) * a - (line2EndY - line2StartY) * b;
+ numerator2 = (line1EndX - line1StartX) * a - (line1EndY - line1StartY) * b;
+ a = numerator1 / denominator;
+ b = numerator2 / denominator;
+ result.x = line1StartX + a * (line1EndX - line1StartX);
+ result.y = line1StartY + a * (line1EndY - line1StartY);
+ if (a > 0 && a < 1) {
+ result.onLine1 = true;
+ }
+ if (b > 0 && b < 1) {
+ result.onLine2 = true;
+ }
+ return result;
+}
+;
var grid = game.addChild(new Grid());
grid.y = 1300;
var barriers = [];
for (var a = 0; a < 4; a++) {
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.