Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: obstacleGraphics is not defined' in or related to this line: 'barrier.y = self.y + (self.height - obstacleGraphics.height) / 2 * Math.sin(barrier.angle);' Line Number: 109
User prompt
Fix Bug: 'ReferenceError: obstacleGraphics is not defined' in or related to this line: 'barrier.x = self.x + (self.width - obstacleGraphics.width) / 2 * Math.cos(barrier.angle);' Line Number: 108
User prompt
barriers should circle around their parent orbit's center at a distance equal to its width.
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: currentTargetOrbit is not defined' in or related to this line: 'if (!currentTargetOrbit == 0) {' Line Number: 84
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: numBarriers is not defined' in or related to this line: 'barrier.angle = index * (Math.PI * 2 / numBarriers);' Line Number: 102
User prompt
complete the orbit.addBarrier function. It should add a barrier object to the orbit, which circles the orbit at speed.
User prompt
Fix Bug: 'Uncaught ReferenceError: numBarriers is not defined' in or related to this line: 'var angle = index / numBarriers * 2 * Math.PI;' Line Number: 101
User prompt
complete the orbit.addBarrier function to add a barrier that circles in that orbit with the passed speed.
User prompt
Fix Bug: 'Uncaught ReferenceError: barrierSpeed is not defined' in or related to this line: 'self.addBarrier(barrierSpeed, j);' Line Number: 90
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
update score display when score is updated
User prompt
display score on top center
User prompt
add 1 player score for each successfull jump
Code edit (1 edits merged)
Please save this source code
User prompt
tint each orbit in a random color on creation
Code edit (7 edits merged)
Please save this source code
User prompt
make sure player stays on topmost zindex after each new orbit is created.
User prompt
Fix Bug: 'ReferenceError: currentTargetOrbit is not defined' in or related to this line: 'player.radius = orbits[currentTargetOrbit].width - 100 / 2;' Line Number: 134
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
/****
* Classes
****/
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = 900;
self.angle = 0;
self.jump = function () {
currentOrbitIndex++;
var targetOrbit = orbits[currentOrbitIndex];
self.angle = Math.atan2(self.y - 2732 / 2, self.x - 2048 / 2);
if (targetOrbit) {
self.radius = (targetOrbit.width - 100) / 2;
} else {
self.radius = 0; // Fallback radius if targetOrbit is not defined
}
self.x = 2048 / 2 + self.radius * Math.cos(self.angle);
self.y = 2732 / 2 + self.radius * Math.sin(self.angle);
scaling = true;
};
self.update = function () {
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var angleSpeed = 0.01;
self.angle = (self.angle || 0) + angleSpeed;
self.x = centerX + self.radius * Math.cos(self.angle);
self.y = centerY + self.radius * Math.sin(self.angle);
};
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.move = function () {
// Obstacle move logic
};
});
// Orbit class
var Orbit = Container.expand(function () {
var self = Container.call(this);
var orbitGraphics = self.attachAsset('orbit1', {
anchorX: 0.5,
anchorY: 0.5
});
orbitGraphics.alpha = 0.5;
self.positionOrbit = function (i) {
self.x = 2048 / 2;
self.y = 2732 / 2;
this.width = 1900 - i * 500;
this.height = 1900 - i * 500;
};
var orbitGraphicsMask = self.attachAsset('blackSphere', {
anchorX: 0.5,
anchorY: 0.5
});
orbitGraphicsMask.width = self.width - 200;
orbitGraphicsMask.height = self.height - 200;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Game variables
// Initialize assets used in this game.
var player;
var orbits = [];
var obstacles = [];
var currentOrbitIndex = 0;
var scaling = false;
var scalingCounter = 0;
// Initialize player
// Initialize orbits
function createOrbits() {
for (var i = 0; i < 5; i++) {
var orbit = game.addChild(new Orbit());
orbit.positionOrbit(i);
orbits.push(orbit);
}
}
createOrbits();
player = game.addChild(new Player());
//player.x = 2048 / 2;
//player.y = 2732 / 2 - 200; // Start the player 200px above the center
// Game logic
game.on('down', function (obj) {
player.jump(currentOrbitIndex);
});
LK.on('tick', function () {
player.update();
if (scaling) {
scalingCounter++;
for (var i = 0; i < orbits.length; i++) {
orbits[i].width++;
orbits[i].height++;
}
if (scalingCounter == 500) {
scaling = false;
scalingCounter = 0;
}
}
// Update orbits
for (var i = 0; i < orbits.length; i++) {
//orbits[i].positionOrbit(i);
}
// Update obstacles
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].move();
if (player.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
// Check if player reached the center
if (player.intersects(orbits[0])) {}
});