User prompt
On tap, make player jump to the next orbit.
Code edit (1 edits merged)
Please save this source code
User prompt
draw a circlular object called orbit1 with a diamter of 1800 pixels in the center
Code edit (1 edits merged)
Please save this source code
User prompt
Make the player circle around the center at a distance of 800 pixels.
Initial prompt
Approaching Orbit
===================================================================
--- original.js
+++ change.js
@@ -7,10 +7,17 @@
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
- self.jump = function () {
- // Player jump logic
+ self.jump = function (currentOrbitIndex) {
+ if (currentOrbitIndex > 0) {
+ currentOrbitIndex--;
+ var targetOrbit = orbits[currentOrbitIndex];
+ self.angle = Math.atan2(self.y - 2732 / 2, self.x - 2048 / 2);
+ var targetRadius = (targetOrbit.width - 100) / 2;
+ self.x = 2048 / 2 + targetRadius * Math.cos(self.angle);
+ self.y = 2732 / 2 + targetRadius * Math.sin(self.angle);
+ }
};
self.update = function () {
var centerX = 2048 / 2;
var centerY = 2732 / 2;
@@ -37,12 +44,21 @@
var orbitGraphics = self.attachAsset('orbit1', {
anchorX: 0.5,
anchorY: 0.5
});
- self.positionOrbit = function () {
+ 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
@@ -69,23 +85,14 @@
orbits.push(orbit);
}
}
createOrbits();
-// Initialize obstacles
-function createObstacles() {
- for (var i = 0; i < 10; i++) {
- var obstacle = game.addChild(new Obstacle());
- obstacle.move();
- obstacles.push(obstacle);
- }
-}
-createObstacles();
player = game.addChild(new Player());
-player.x = 2048 / 2;
-player.y = 2732 / 2 - 200; // Start the player 200px above the center
+//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();
+ player.jump(currentOrbitIndex);
});
LK.on('tick', function () {
player.update();
// Update orbits
@@ -100,12 +107,6 @@
LK.showGameOver();
}
}
// Check if player reached the center
- if (player.intersects(orbits[0])) {
- LK.setScore(LK.getScore() + 1);
- // Reset player to the last orbit
- player.x = orbits[orbits.length - 1].x;
- player.y = orbits[orbits.length - 1].y;
- currentOrbitIndex = orbits.length - 1;
- }
+ if (player.intersects(orbits[0])) {}
});
\ No newline at end of file