User prompt
Farid Enlarge
User prompt
Let Farid be a little bigger
User prompt
Let the obstacle be a little bigger
User prompt
Put an image of the Azerbaijani flag in the background
User prompt
Farid, you jump higher and don't hit the obstacle
User prompt
Let Farid be bigger
User prompt
Make the obstacle smaller
User prompt
Let Farid jump more
User prompt
Reduce the size of the mushroom
Initial prompt
Farid Jump
/**** * Classes ****/ //<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: 0.5, scaleY: 0.5 }); self.speedY = 0; self.gravity = 0.5; self.jumpStrength = -15; // 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) { self.y = 2732 - faridGraphics.height / 2; self.speedY = 0; } }; // Function to make Farid jump self.jump = function () { if (self.y >= 2732 - faridGraphics.height / 2) { self.speedY = self.jumpStrength; } }; }); // Class for obstacles var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = -5; // Update function for obstacles self.update = function () { self.x += self.speedX; // 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 ****/ // Initialize Farid var farid = game.addChild(new Farid()); farid.x = 2048 / 2; farid.y = 2732 - 100; // 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, 2000); // Handle touch down event to make Farid jump game.down = function (x, y, obj) { farid.jump(); }; // 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(); } } };
===================================================================
--- original.js
+++ change.js
@@ -1,93 +1,95 @@
-/****
+/****
* Classes
-****/
+****/
//<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
- });
- self.speedY = 0;
- self.gravity = 0.5;
- self.jumpStrength = -15;
- // 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) {
- self.y = 2732 - faridGraphics.height / 2;
- self.speedY = 0;
- }
- };
- // Function to make Farid jump
- self.jump = function () {
- if (self.y >= 2732 - faridGraphics.height / 2) {
- self.speedY = self.jumpStrength;
- }
- };
+ var self = Container.call(this);
+ var faridGraphics = self.attachAsset('farid', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.5,
+ scaleY: 0.5
+ });
+ self.speedY = 0;
+ self.gravity = 0.5;
+ self.jumpStrength = -15;
+ // 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) {
+ self.y = 2732 - faridGraphics.height / 2;
+ self.speedY = 0;
+ }
+ };
+ // Function to make Farid jump
+ self.jump = function () {
+ if (self.y >= 2732 - faridGraphics.height / 2) {
+ self.speedY = self.jumpStrength;
+ }
+ };
});
// Class for obstacles
var Obstacle = Container.expand(function () {
- var self = Container.call(this);
- var obstacleGraphics = self.attachAsset('obstacle', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speedX = -5;
- // Update function for obstacles
- self.update = function () {
- self.x += self.speedX;
- // Remove obstacle if it goes off screen
- if (self.x < -obstacleGraphics.width / 2) {
- self.destroy();
- }
- };
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speedX = -5;
+ // Update function for obstacles
+ self.update = function () {
+ self.x += self.speedX;
+ // 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
+ backgroundColor: 0x87CEEB // Init game with sky blue background
});
-/****
+/****
* Game Code
-****/
+****/
// Initialize Farid
var farid = game.addChild(new Farid());
farid.x = 2048 / 2;
farid.y = 2732 - 100;
// 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);
+ 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, 2000);
// Handle touch down event to make Farid jump
game.down = function (x, y, obj) {
- farid.jump();
+ farid.jump();
};
// 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();
- }
- }
+ 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();
+ }
+ }
};
\ No newline at end of file