User prompt
Use the jump sound when Farid jumps
User prompt
The more you play, the harder it gets
User prompt
As the score increases, the speed of the obstacle increases
User prompt
Make the score text bold
User prompt
Accelerate the arrival of Obstacle over time
User prompt
Put a black background under the score inscription
User prompt
Make the game more difficult as you overcome obstacles
User prompt
Complicate the game
User prompt
Let the obstacle come faster and faster
User prompt
Make the game harder and harder
User prompt
Make the game harder and harder
User prompt
Let Farid be small in size
User prompt
Let Farid be in large size
User prompt
Obstacle I also rises to the floor
User prompt
Add a floor to the game and Farid will run on it
User prompt
Add score
User prompt
Shrink Farid
User prompt
Enlarge Farid
User prompt
Shrink Farid
User prompt
Add a gauge that counts successful jumps
User prompt
Enlarge Farid
User prompt
Add a timer to the game and it will count successful jumps
User prompt
Enlarge Farid i a little more
User prompt
Make Farid run on the floor
User prompt
Bring Farid to the largest size possible
/**** * Classes ****/ // Add a floor asset //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Class for the main character, Farid var Farid = Container.expand(function () { var self = Container.call(this); var faridGraphics = self.attachAsset('farid', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); self.speedY = 0; self.gravity = 0.7; self.jumpStrength = -30; // Update function for Farid self.update = function () { self.speedY += self.gravity; self.y += self.speedY; // Prevent Farid from falling below the ground if (self.y > 2732 - faridGraphics.height / 2 - 100) { // Adjust the ground level self.y = 2732 - faridGraphics.height / 2 - 100; // Adjust the ground level self.speedY = 0; } }; // Function to make Farid jump self.jump = function () { if (self.y >= 2732 - faridGraphics.height / 2 - 100) { // Adjust the ground level self.speedY = self.jumpStrength; // Play jump sound LK.getSound('Fx').play(); } }; }); // Class for obstacles var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); self.speedX = -5; // Update function for obstacles self.update = function () { self.x += self.speedX; self.y = 2732 - obstacleGraphics.height / 2 - 50; // Remove obstacle if it goes off screen if (self.x < -obstacleGraphics.width / 2) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Init game with sky blue background }); /**** * Game Code ****/ var background = game.attachAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Initialize Farid var farid = game.addChild(new Farid()); farid.x = 2048 / 2; farid.y = 2732 - 100; // Add the floor to the game var floor = game.attachAsset('floor', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 - 50 }); // Array to keep track of obstacles var obstacles = []; // Function to spawn a new obstacle function spawnObstacle() { var obstacle = new Obstacle(); obstacle.x = 2048 + obstacle.width / 2; obstacle.y = 2732 - obstacle.height / 2; obstacles.push(obstacle); game.addChild(obstacle); } // Set interval to spawn obstacles var obstacleInterval = LK.setInterval(spawnObstacle, 1500); // Handle touch down event to make Farid jump game.down = function (x, y, obj) { farid.jump(); }; // Initialize score var score = 0; var scoreBg = LK.getAsset('box', { width: 300, height: 200, color: 0x000000 }); scoreBg.anchor.set(0.5, 0); LK.gui.top.addChild(scoreBg); var scoreTxt = new Text2(score.toString(), { size: 150, fill: 0xFFFFFF, font: "'GillSans-Bold',Impact,'Arial Black',Tahoma" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Update function for the game game.update = function () { farid.update(); // Update all obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].update(); // Check for collision with Farid if (farid.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Increase score when Farid jumps over an obstacle if (farid.x > obstacles[i].x + obstacles[i].width / 2 && !obstacles[i].scored) { score++; scoreTxt.setText(score.toString()); obstacles[i].scored = true; } // Increase the speed of obstacles over time obstacles[i].speedX -= 0.1; } };
===================================================================
--- original.js
+++ change.js
@@ -31,8 +31,10 @@
self.jump = function () {
if (self.y >= 2732 - faridGraphics.height / 2 - 100) {
// Adjust the ground level
self.speedY = self.jumpStrength;
+ // Play jump sound
+ LK.getSound('Fx').play();
}
};
});
// Class for obstacles