User prompt
I'm sorry but the time counter does not work the way I want to work. It doesn't response the to the changes when I want to. Please help me improve
User prompt
When time counter reaches -5000 change background for 5 sec to -5000image
User prompt
Add time counter. Place it to the right top corner. It starts at -6000. When hero touches food or food2m remove 100 from time counter. When time counter reaches -5000 change background for -5000image for 5 sec.
User prompt
Remove time counter
User prompt
Add new game logic. When time counter reaches -5000 make -5000image appear for 3 sec
User prompt
Add new game logic. When time counter reaches -5000 make -5000image appear.
User prompt
Add new game logic. When time counter reaches -5000 stop the game. Make -5000image appear. After the click make it disappear and countinue the game
User prompt
Please fix the bug: 'TypeError: game.pause is not a function' in or related to this line: 'game.pause();' Line Number: 240
User prompt
Add new game logic. When time counter reaches -5000 stop the game. Make -5000image appear. After the click make it disappear and countinue the game
User prompt
Add new game logic. When time counter reaches -5000 stop the game. Make -5000image appear. After the click make it disappear and countinue the game
User prompt
Add new game logic. When time counter reaches -5000 stop the game. Make -5000image appear. After the click make it disappear and countinue the game
User prompt
Add new game logic
User prompt
Make -5000image appear when time counter reaches -5000
User prompt
After reching -5000 on time counter, add -5000image asset.
User prompt
After reaching -5000 stop the game and make -5000image appear. After clicking continue the game
User prompt
create a background
User prompt
Create a background
User prompt
Create a backgrond for the game. A jungle for the with a cave
User prompt
Add obstacle3m asset with the same logic as food and food2m
User prompt
make obstacles and foods spawn logic frequency equal
User prompt
Create obstacle2m asset, with the same logic as obstacle
User prompt
Delete wide obstacle
User prompt
add more frequent food and food2m
User prompt
Make the game less difficult
User prompt
Make food2m appear as frequent as food. Use the same logic for food2m as food.
/**** * Classes ****/ var Background = Container.expand(function () { var self = Container.call(this); var backgroundGraphics = self.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 2; }); var Food = Container.expand(function () { var self = Container.call(this); var foodGraphics = self.attachAsset('food', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var Food2m = Container.expand(function () { var self = Container.call(this); var food2mGraphics = self.attachAsset('food2m', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); //<Assets used in the game will automatically appear here> // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Hero update logic if (self.x < 0) { self.x = 0; } else if (self.x > 2048) { self.x = 2048; } }; // Removed jump logic }); var Negative5000Image = Container.expand(function () { var self = Container.call(this); var imageGraphics = self.attachAsset('-5000image', { anchorX: 0.5, anchorY: 0.5 }); self.x = 2048 / 2; self.y = 2732 / 2; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); var Obstacle2m = Container.expand(function () { var self = Container.call(this); var obstacle2mGraphics = self.attachAsset('obstacle2m', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); var Obstacle3m = Container.expand(function () { var self = Container.call(this); var obstacle3mGraphics = self.attachAsset('obstacle3m', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var background = new Background(); game.addChild(background); var hero; var obstacles = []; var scoreTxt; var score = 0; var timeTxt; var timeElapsed = -6000; var gameSpeed = 5; // Initialize hero function initHero() { hero = new Hero(); hero.x = 1024; // Center horizontally hero.y = 2500; game.addChild(hero); } // Initialize score text function initScore() { scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); } // Update score function updateScore() { score += 1; scoreTxt.setText(score); } // Spawn obstacle function spawnObstacle() { var randomValue = Math.random(); if (randomValue < 0.25) { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.y = -obstacle.height / 2; obstacles.push(obstacle); game.addChild(obstacle); } else if (randomValue < 0.5) { var food = new Food(); food.x = Math.random() * 2048; food.y = -food.height / 2; obstacles.push(food); game.addChild(food); } else if (randomValue < 0.75) { var obstacle2m = new Obstacle2m(); obstacle2m.x = Math.random() * 2048; obstacle2m.y = -obstacle2m.height / 2; obstacles.push(obstacle2m); game.addChild(obstacle2m); } else if (randomValue < 0.875) { var obstacle3m = new Obstacle3m(); obstacle3m.x = Math.random() * 2048; obstacle3m.y = -obstacle3m.height / 2; obstacles.push(obstacle3m); game.addChild(obstacle3m); } else { var food2m = new Food2m(); food2m.x = Math.random() * 2048; food2m.y = -food2m.height / 2; obstacles.push(food2m); game.addChild(food2m); } } // Handle game over function handleGameOver() { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Handle move event function handleMove(x, y, obj) { if (hero) { hero.x = x; } } // Handle down event function handleDown(x, y, obj) { // Removed call to hero jump } // Game update function game.update = function () { // Update hero if (hero) { hero.update(); } // Update obstacles for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].update(); if (hero && obstacles[i] instanceof Obstacle && hero.intersects(obstacles[i])) { handleGameOver(); } else if (hero && (obstacles[i] instanceof Food || obstacles[i] instanceof Food2m) && hero.intersects(obstacles[i])) { obstacles[i].destroy(); obstacles.splice(i, 1); updateScore(); timeElapsed += 100; // Add 100 to the time counter timeTxt.setText(timeElapsed); // Update the time counter text } } // Spawn new obstacle if (LK.ticks % (180 / gameSpeed) == 0) { spawnObstacle(); } // Update score if (LK.ticks % 60 == 0) { updateScore(); } }; // Initialize game elements initHero(); initScore(); initTimeCounter(); // Set event listeners game.move = handleMove; game.down = handleDown; // Initialize time counter text function initTimeCounter() { timeTxt = new Text2(timeElapsed.toString(), { size: 150, fill: "#ffffff" }); timeTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timeTxt); timeTxt.setText(timeElapsed); // Set initial time } // Update time counter function updateTimeCounter() { timeElapsed += 1; timeTxt.setText(timeElapsed); if (timeElapsed === -5000) { var negative5000Image = new Negative5000Image(); game.addChild(negative5000Image); var originalBackground = background; background.destroy(); background = negative5000Image; LK.setTimeout(function () { background.destroy(); background = originalBackground; game.addChild(background); }, 5000); } }
===================================================================
--- original.js
+++ change.js
@@ -251,12 +251,8 @@
});
timeTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(timeTxt);
timeTxt.setText(timeElapsed); // Set initial time
- // Update time counter every second
- if (LK.ticks % 60 == 0) {
- updateTimeCounter();
- }
}
// Update time counter
function updateTimeCounter() {
timeElapsed += 1;
a caveman with a club, seen from above. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of an apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of a delicious meat. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A animated image of a stone boulder. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A animated image of a mommoth. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A animated image of a aggressive caveman with a club. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A road in a jungle with a cave nearby
An animated image of a wooden wheel with a sign: The invention of the wheel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of a desert with a pyramid. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of an egyptian warrior. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of an aggressive egyptian warrior. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of a wooden arrow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of a lion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of an unfinished pyramid, with a label 'The building of the Pyramids of Giza. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of an ancient greek city with an Acropolis. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of an ancient greek warrior. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of an aggressive ancient greek warrior. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image of the colosseum. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image a medieval city with a castle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image a medieval knight. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image an aggressive medieval knight. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An animated image a fierce wolf. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.