User prompt
20% of the planets have planets revolving around them
User prompt
add a speech bubble to the player when it is jumping
Code edit (2 edits merged)
Please save this source code
User prompt
show the score on top
User prompt
show the UI score
User prompt
some planets have planets revolving around them
User prompt
fix the issue
Code edit (7 edits merged)
Please save this source code
User prompt
create a graphic for the RevolvingPlanet
Code edit (5 edits merged)
Please save this source code
User prompt
scale the revolvingplanet half to the size of the parentplanet
Code edit (2 edits merged)
Please save this source code
User prompt
make the player also collide with the revolvingplanet, just like the planet
User prompt
fix that the speechbubble is shown
User prompt
if the player hits a revolvingplanet, increase the score
User prompt
set the revolvingplanet to visible false, if the player collides with it
Code edit (4 edits merged)
Please save this source code
User prompt
Only check collision with planets which are visible
User prompt
if the revolvingplanet.parentPlanet respawns make sure to make it visible again
Code edit (1 edits merged)
Please save this source code
User prompt
Migrate to the latest version of LK
User prompt
play the jump sound whenver the player jumps
User prompt
add a sound "collect" and play it when the player collides with the revolvingplanet
User prompt
play a sound gameover when the game is over
User prompt
play a sound impact when the player collides lands on a planet
===================================================================
--- original.js
+++ change.js
@@ -22,23 +22,8 @@
}
};
self.speed = Math.random() * 3 + 2; // Assign a random speed between 2 and 5 to each planet
});
-// RevolvingPlanet class for the planets that revolve around other planets
-var RevolvingPlanet = Planet.expand(function () {
- var self = Planet.call(this);
- self.parentPlanet = null;
- self.angle = Math.random() * Math.PI * 2; // Assign a random initial angle
- self.distance = Math.random() * 200 + 100; // Assign a random distance from the parent planet
- self.speed = Math.random() * 0.02 + 0.01; // Assign a random speed
- self.update = function () {
- if (self.parentPlanet) {
- self.angle += self.speed; // Update the angle
- self.x = self.parentPlanet.x + Math.cos(self.angle) * self.distance; // Update the x position
- self.y = self.parentPlanet.y + Math.sin(self.angle) * self.distance; // Update the y position
- }
- };
-});
// Player class for the main character
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
@@ -68,8 +53,28 @@
self.velocity.y += 0.98; // Gravity effect
self.speechBubble.visible = true;
};
});
+// RevolvingPlanet class for the planets that revolve around other planets
+var RevolvingPlanet = Container.expand(function () {
+ var self = Container.call(this);
+ var planetGraphics = self.attachAsset('planet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ planetGraphics.scale.set(0.2, 0.2);
+ self.parentPlanet = null;
+ self.angle = Math.random() * Math.PI * 2; // Assign a random initial angle
+ self.distance = Math.random() * 200 + 100; // Assign a random distance from the parent planet
+ self.speed = Math.random() * 0.02 + 0.01; // Assign a random speed
+ self.update = function () {
+ if (self.parentPlanet) {
+ self.angle += self.speed; // Update the angle
+ self.x = self.parentPlanet.x + Math.cos(self.angle) * self.distance; // Update the x position
+ self.y = self.parentPlanet.y + Math.sin(self.angle) * self.distance; // Update the y position
+ }
+ };
+});
/****
* Initialize Game
****/
@@ -116,22 +121,8 @@
var revolvingPlanet = new RevolvingPlanet();
revolvingPlanet.parentPlanet = planet;
game.addChild(revolvingPlanet);
planets.push(revolvingPlanet);
- // Check if any planets have moved off the bottom of the screen
- for (var j = planets.length - 1; j >= 0; j--) {
- if (planets[j].y > 2732 + planets[j].height / 2) {
- // Remove the planet from the game and the planets array
- planets[j].destroy();
- planets.splice(j, 1);
- // Spawn a new planet at the top of the screen
- var newPlanet = new Planet();
- newPlanet.x = Math.random() * 2048;
- newPlanet.y = -newPlanet.height / 2;
- game.addChild(newPlanet);
- planets.push(newPlanet);
- }
- }
}
}
// Create player
planets[0].x = 1024; // Start the first planet in the middle of the screen horizontally
planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. transparent background
monkey astronaut. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. transparent background
space background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. transparent background
speech bubble saying "wee". game asset. 2d. 8bit. no background. transparent background.
banana. game asset. 2d. 8bit. no background. transparent background.