Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: rainbowGraphics is not defined' in or related to this line: 'rainbowGraphics.tint = '0xffffff';' Line Number: 59
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of null (reading 'alpha')' in or related to this line: 'powerupText.alpha -= 1 / fadeStep;' Line Number: 248
User prompt
Fix Bug: 'Timeout.tick error: LK.effects.fadeOut is not a function' in or related to this line: 'LK.effects.fadeOut(powerupText, 3000, function () {' Line Number: 243
User prompt
Fix Bug: 'Timeout.tick error: LK.effects.fadeObject is not a function' in or related to this line: 'LK.effects.fadeObject(powerupText, 0, 3000, function () {' Line Number: 243
User prompt
Fix Bug: 'Timeout.tick error: LK.effects.fadeOut is not a function' in or related to this line: 'LK.effects.fadeOut(powerupText, 3000, function () {' Line Number: 243
User prompt
once added in showpoweruptext, poweruptext should fade out over the course of 3 seconds
Code edit (2 edits merged)
Please save this source code
User prompt
make poweruptext disappear on click, if it exists
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: ball is not defined' in or related to this line: 'console.log('collision occurred: (obstacle:', t.radius, t.angle, t.x, t.y, ') , (player: ', ball.radius, ball.angle, ball.x, ball.y);' Line Number: 345
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: localToGlobal is not defined' in or related to this line: 'var globalPos1 = localToGlobal(object1);' Line Number: 271
Code edit (6 edits merged)
Please save this source code
User prompt
update the getglobalposition function to account for parent objects having been scaled up or down
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getChildAt')' in or related to this line: 'LK.effects.flashScreen(obstacles[i].parent.getChildAt(0).getTint(), 1000);' Line Number: 342
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getChildAt')' in or related to this line: 'LK.effects.flashScreen(obstacles[i].parent.getChildAt(0).tint, 1000);' Line Number: 342
Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'orbitGraphics')' in or related to this line: 'LK.effects.flashScreen(obstacles[i].parent.orbitGraphics.tint, 1000);' Line Number: 342
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -4,9 +4,9 @@
/****
TODO:
* Maybe player should change orbit direction (and/or speed) with the orbit he jumps into?
* Make sure orbits don't have too many obstacles.
-* Maybe pause player and obstacle updating while scaling?
+* Maybe skip player and obstacle updating while scaling?
* Current min and max speeds of obstacles should be closer to each other.
* Make check of circular collision, considering actual display size and stage coordinates of obstacles. (Or even just a forgiving distanc check).
* Maybe background should tint with an offset on the colorwheel?
* Rotate orbits with obstacles statically distributed on them instead of calculating obstacle positions (for performance).
@@ -238,8 +238,42 @@
orbits.push(orbit);
}
}
createOrbits();
+function getGlobalPosition(object) {
+ var position = {
+ x: object.x,
+ y: object.y
+ };
+ var parent = object.parent;
+ var scale = {
+ x: 1,
+ y: 1
+ };
+ while (parent) {
+ position.x = position.x * scale.x + parent.x;
+ position.y = position.y * scale.y + parent.y;
+ scale.x *= parent.scaleX || 1;
+ scale.y *= parent.scaleY || 1;
+ parent = parent.parent;
+ }
+ return position;
+}
+function calculateDistance(object1, object2) {
+ var globalPos1 = getGlobalPosition(object1);
+ var globalPos2 = getGlobalPosition(object2);
+ var dx = globalPos1.x - globalPos2.x;
+ var dy = globalPos1.y - globalPos2.y;
+ return Math.sqrt(dx * dx + dy * dy);
+}
+function radIntersects(a, b, m) {
+ /*
+ var dx = (a.x - b.x) * (a.x - b.x);
+ var dy = (a.y - b.y) * (a.y - b.y);
+ return dx + dy < m * m;*/
+ var dist = calculateDistance(a, b);
+ return dist < m ? true : false;
+}
// Add instruction text at the bottom of the screen
var instructionText = new Text2('Tap to jump to the next orbit.\nDon\'t hit the red obstacles.', {
size: 50,
fill: "#bbbbbb",
@@ -330,9 +364,10 @@
// Update obstacles
for (var i = obstacles.length - 1; i > 0; i--) {
if (obstacles[i] && !obstacles[i]._destroyed) {
obstacles[i].move();
- if (player.intersects(obstacles[i])) {
+ //if (player.intersects(obstacles[i])) {
+ if (radIntersects(player, obstacles[i], 100)) {
if (obstacles[i] instanceof Powerup1) {
obstacles[i].destroy();
obstacles[i]._destroyed = true;
LK.effects.flashScreen(0xffffff, 1000);