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
@@ -53,30 +53,28 @@
self.velocity.y += 0.98; // Gravity effect
self.speechBubble.visible = true;
};
});
-// Score display class
-var ScoreDisplay = Text2.expand(function () {
- var self = Text2.call(this, '0', {
- size: 150,
- fill: "#ffffff"
- });
- self.anchor.set(0.5, 0); // Sets anchor to the center of the top edge of the text.
- self.update = function () {
- self.setText(LK.getScore()); // Update the score text
- };
-});
/****
* Initialize Game
****/
+// Initialize a Text2 object to display the score
+// Add the score text to the GUI overlay.
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
+// Initialize a Text2 object to display the score
+var scoreTxt = new Text2('0', {
+ size: 150,
+ fill: "#ffffff"
+});
+scoreTxt.anchor.set(0.5, 0); // Sets anchor to the center of the top edge of the text.
+LK.gui.top.addChild(scoreTxt);
var planets = [];
var background = game.attachAsset('background', {
anchorX: 0.0,
anchorY: 0.0
@@ -86,11 +84,8 @@
var currentPlanet;
function setupGame() {
// Create player
player = new Player();
- // Create score display
- var scoreDisplay = new ScoreDisplay();
- LK.gui.top.addChild(scoreDisplay); // Add the score display to the GUI overlay
player.x = 1024; // Start in the middle of the screen horizontally
player.y = 1366; // Start in the middle of the screen vertically
game.addChild(player);
// Create planets
@@ -136,8 +131,10 @@
if (distance < player.width / 2 + planet.radius) {
if (!player.onGround) {
// Increase score when player lands on a planet
LK.setScore(LK.getScore() + 1);
+ // Update the score display
+ scoreTxt.setText(LK.getScore());
}
player.onGround = true;
player.velocity.y = 0;
currentPlanet = planet;
@@ -162,10 +159,8 @@
planets.forEach(function (planet) {
planet.update();
});
checkCollisions();
- // Update the score display
- scoreDisplay.update();
// Check if the player is out of the screen
if (player.x < 0 || player.x > 2048 || player.y < 0 || player.y > 2732) {
// End the game
LK.showGameOver();
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.