User prompt
make wide obcatcle spawn less frequent
User prompt
create a new type of obctacle. make it more wider as wide as the screen. The hero must jump across it with clicl
User prompt
Make obtacles bigger and harder to pass
User prompt
make hero move horizontally
User prompt
Make obtacle descend from random spots from the top
User prompt
Please fix the bug: 'TypeError: LK.isKeyDown is not a function' in or related to this line: 'if (LK.isKeyDown('ArrowLeft')) {' Line Number: 21
User prompt
make hero move in a horizontal way
User prompt
make obstacles descend from the top
User prompt
Please turn the field 90 degrees ledt
Initial prompt
History Runner
/**** * Classes ****/ //<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; } }; self.jump = function () { // Hero jump logic self.y -= 200; // Adjust jump height as needed LK.setTimeout(function () { self.y += 200; // Return to original position after jump }, 500); // Adjust jump duration as needed }; }); // 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 = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); // WideObstacle class var WideObstacle = Container.expand(function () { var self = Container.call(this); var wideObstacleGraphics = self.attachAsset('wideObstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; 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 hero; var obstacles = []; var scoreTxt; var score = 0; 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() { if (Math.random() < 0.8) { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.y = -obstacle.height / 2; obstacles.push(obstacle); game.addChild(obstacle); } else { var wideObstacle = new WideObstacle(); wideObstacle.x = 1024; // Center horizontally wideObstacle.y = -wideObstacle.height / 2; obstacles.push(wideObstacle); game.addChild(wideObstacle); } } // 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) { if (hero) { 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 && hero.intersects(obstacles[i])) { handleGameOver(); } } // Spawn new obstacle if (LK.ticks % (120 / gameSpeed) == 0) { spawnObstacle(); } // Update score if (LK.ticks % 60 == 0) { updateScore(); } }; // Initialize game elements initHero(); initScore(); // Set event listeners game.move = handleMove; game.down = handleDown;
===================================================================
--- original.js
+++ change.js
@@ -94,9 +94,9 @@
scoreTxt.setText(score);
}
// Spawn obstacle
function spawnObstacle() {
- if (Math.random() < 0.5) {
+ if (Math.random() < 0.8) {
var obstacle = new Obstacle();
obstacle.x = Math.random() * 2048;
obstacle.y = -obstacle.height / 2;
obstacles.push(obstacle);
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.