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
User prompt
Fix Bug: 'ReferenceError: barrier is not defined' in or related to this line: 'barrier.angle = 0;' Line Number: 170
Code edit (7 edits merged)
Please save this source code
User prompt
when player taps, remove the instructiontext from gui
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: center is not defined' in or related to this line: 'var instructionText = new Text2('Tap to jump to the next orbit.\nDon\'t hit the red obstacles.', {' Line Number: 227
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'gui')' in or related to this line: 'scoreTxt.LK.gui.top.addChild(scoreTxt);' Line Number: 216
Code edit (4 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'bottom')' in or related to this line: 'LK.top.bottom.addChild(instructionText);' Line Number: 236
Code edit (6 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -2,21 +2,18 @@
* Classes
****/
/****
TODO:
-* Make sure obstacles can't spawn directly on player angle with same speed at start, making first jump impossible.
* Maybe player should change orbit direction (and/or speed) with the orbit he jumps into?
-* Make sure orbits don't have too many obstacles (as currently possible).
+* Make sure orbits don't have too many obstacles.
* Maybe pause player and obstacle updating while scaling?
-* Maybe make jumping faster to allow faster consecutive jumps.
* Current min and max speeds of obstacles should be closer to each other.
-* Some rings could contain a single powerup (static, so player would always be able to circle around and get it.)
-* Or maybe just no obstacles, as a breather.
-* Every play should start at a different index of the rainbow color wheel.
-* Player could be a white dot for max contrast.
-* Make check of circular collision, considering actual display size and stage coordinates of obstacles.
+* Some orbits could contain a single powerup (static, so player would always be able to circle around and get it.)
+* Or maybe just orbits with no obstacles, as a breather.
+* 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 instead of calculating obstacle positions.
+* Rotate orbits with obstacles statically distributed on them instead of calculating obstacle positions (for performance).
+* Would also be cool to be able to jump in AND out of orbits, but hard to implement. Or maybe just tap on the orbit to go to?
****/
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
@@ -81,8 +78,27 @@
self.x = self.radius * Math.cos(self.angle);
self.y = self.radius * Math.sin(self.angle);
};
});
+// Powerup class
+var Powerup1 = Container.expand(function () {
+ var self = Container.call(this);
+ var powerup1Graphics = self.attachAsset('powerup1', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ //self.angleSpeed = 0.01;
+ self.orbitSpeed = 0;
+ self.move = function () {
+ // Powerups don't move
+ /*
+ self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width);
+ self.angle = (self.angle || 0) + self.orbitSpeed;
+ self.x = self.radius * Math.cos(self.angle);
+ self.y = self.radius * Math.sin(self.angle);
+ */
+ };
+});
// Orbit class
var Orbit = Container.expand(function () {
var self = Container.call(this);
var orbitGraphics = self.attachAsset('orbit1', {
@@ -103,8 +119,13 @@
this.numBarriers = 1 + Math.floor(Math.random() * (i + currentOrbitIndex));
if (this.numBarriers > 12) {
this.numBarriers = 12;
}
+ // Add powerup to some orbits
+ if ((i + currentOrbitIndex) % 6 == 0) {
+ this.numBarriers = 0;
+ self.addPowerup(0);
+ }
//self.barrierSpeed = Math.random() * currentOrbitIndex + 1 / 20;
self.barrierSpeed = 0.01 + Math.random() * 0.015 * self.direction;
for (var j = 0; j < this.numBarriers; j++) {
self.addBarrier(self.barrierSpeed, j);
@@ -134,8 +155,14 @@
};*/
self.addChild(barrier);
obstacles.push(barrier);
};
+ self.addPowerup = function (index) {
+ var powerup = new Powerup1();
+ powerup.angle = 0;
+ self.addChild(powerup);
+ obstacles.push(powerup);
+ };
});
/****
* Initialize Game
@@ -179,16 +206,8 @@
return hex.length === 1 ? '0' + hex : hex;
};
return '0x' + toHex(r) + toHex(g) + toHex(b);
}
-var rainbowColors = function () {
- var colors = [];
- for (var i = 0; i < 15; i++) {
- var hue = i * 24 % 360;
- colors.push(hsvToHex(hue / 360, 1, 1));
- }
- return colors;
-}();
//console.log(rainbowColors);
// Initialize assets used in this game.
// Game variables
var player;
@@ -198,9 +217,18 @@
var scaling = false;
var scalingCounter = 0;
var scalingSpeed = 50; //25;
var scalingTarget = 500;
-var orbitsCreated = 0;
+var numColors = 18;
+var orbitsCreated = Math.floor(Math.random() * numColors); //0;
+var rainbowColors = function () {
+ var colors = [];
+ for (var i = 0; i < numColors; i++) {
+ var hue = i * (360 / numColors) % 360;
+ colors.push(hsvToHex(hue / 360, 1, 1));
+ }
+ return colors;
+}();
// Initialize player
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"