User prompt
When you reach 3 minutes, the game is clear
User prompt
Fix Bug: 'ReferenceError: global is not defined' in this line: 'self.x -= global.elapsedTime > 120 ? 10 : 5;' Line Number: 45
User prompt
Make character's jump height slightly lower
User prompt
Fix Bug: 'ReferenceError: elapsedTime is not defined' in this line: 'self.x -= elapsedTime > 120 ? 8 : 5;' Line Number: 35
User prompt
Fix Bug: 'ReferenceError: global is not defined' in this line: 'self.x -= global.elapsedTime > 120 ? 8 : 5;' Line Number: 35
User prompt
Fix Bug: 'ReferenceError: elapsedTime is not defined' in this line: 'self.x -= elapsedTime > 120 ? 8 : 5;' Line Number: 35
User prompt
After 2 minutes from the start, speed up the obstacles
User prompt
If you touch the obstacle three times, the game is over
User prompt
Please make it so that touching an obstacle up to three times does not result in game over!
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'obstacleSpeed')' in this line: 'self.x -= game.obstacleSpeed;' Line Number: 35
User prompt
Fix Bug: 'ReferenceError: obstacleSpeed is not defined' in this line: 'self.x -= obstacleSpeed;' Line Number: 35
User prompt
After 2 minutes from the start, speed up the obstacle to the left
User prompt
Now, make one meat item appear every 30 seconds
User prompt
Increase the chance of a meatItem appearing to 15% every 40 seconds.
User prompt
Measure the time from start to game over and display it in the top right corner!
User prompt
Please display the time from start to game over in the top right corner
User prompt
var MeatItem = Container.expand(function () { var self = Container.call(this); var meatGraphics = self.createAsset('meat', 'Meat item', 0.5, 0.5); meatGraphics.scale.set(1); self.move = function () { self.x -= 2; if (self.x + self.width / 2 < 0) { self.x = 2048 + self.width / 2; self.y = Math.random() * (2732 - self.height); } }; self.effect = function (character) { character.beamMode = true; character.beamEndTime = Date.now() + 20000; }; }); var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.createAsset('cloud', 'Cloud in the sky', 0.5, 0.5); cloudGraphics.scale.set(2); cloudGraphics.alpha = 0.8; self.move = function () { self.x -= 2; if (self.x + self.width / 2 < 0) { self.x = 2048 + self.width / 2; self.y = Math.random() * (2732 - self.height); } }; }); var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.createAsset('character', 'Main character', .5, .5); characterGraphics.scale.set(1.5); self.beamMode = false; self.beamEndTime = 0; self.velocityY = 0; self.jump = function () { self.velocityY = -30; }; self.fall = function () { if (!self.beamMode) { self.velocityY += 1.2; self.y += self.velocityY; } else if (Date.now() < self.beamEndTime) { self.x += 10; } else { self.beamMode = false; } if (self.y > 2732 - self.height / 2 || self.y < self.height / 2) { LK.showGameOver(); } }; }); var Castle = Container.expand(function () { var self = Container.call(this); var castleGraphics = self.createAsset('castle', 'Castle obstacle', .5, .5); castleGraphics.scale.set(2.5); self.move = function () { self.x -= 5; }; }); var EnhancedCastle = Container.expand(function () { var self = Container.call(this); var castleGraphics = self.createAsset('castle', 'Enhanced Castle obstacle', .5, .5); castleGraphics.scale.set(3.5); self.move = function () { self.x -= 5; }; }); var Game = Container.expand(function () { var self = Container.call(this); this.meatItem = null; var clouds = []; for (var i = 0; i < 5; i++) { var cloud = new Cloud(); cloud.x = Math.random() * 2048; cloud.y = Math.random() * (2732 - cloud.height); clouds.push(cloud); self.addChild(cloud); } LK.on('tick', function () { for (var i = 0; i < clouds.length; i++) { clouds[i].move(); } }); LK.stageContainer.setBackgroundColor(0x87CEEB); var startTime = Date.now(); var elapsedTime = 0; var character = self.addChild(new Character()); var castles = []; character.x = 2048 / 2; character.y = 2732 / 2; var timerTxt = new Text2('0:00', { size: 150, fill: "#ffffff" }); timerTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timerTxt); stage.on('down', function (obj) { character.jump(); }); LK.on('tick', function () { character.fall(); for (var i = 0; i < castles.length; i++) { castles[i].move(); if (castles[i].x + castles[i].width / 2 < 0) { castles[i].destroy(); castles.splice(i, 1); } else if (character.intersects(castles[i])) { LK.showGameOver(); } } if (this.meatItem && character.intersects(this.meatItem)) { this.meatItem.effect(character); this.meatItem.destroy(); this.meatItem = null; } elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2); timerTxt.setText(elapsedTime + 's'); if (elapsedTime > 60) { if (LK.ticks % 60 == 0) { var newCastle = new EnhancedCastle(); newCastle.x = 2048 + newCastle.width / 2; newCastle.y = Math.random() * (2732 - newCastle.height); castles.push(newCastle); self.addChild(newCastle); } } else { if (Math.random() < 0.05 && !this.meatItem) { meatItem = new MeatItem(); meatItem.x = 2048 + meatItem.width / 2; meatItem.y = Math.random() * (2732 - meatItem.height); self.addChild(meatItem); } else if (LK.ticks % 80 == 0) { var newCastle = new Castle(); newCastle.x = 2048 + newCastle.width / 2; newCastle.y = Math.random() * (2732 - newCastle.height); castles.push(newCastle); self.addChild(newCastle); } } }); });
User prompt
Fix Bug: 'ReferenceError: elapsedTime is not defined' in this line: 'LK.showGameOver(elapsedTime + 's');' Line Number: 50
User prompt
Fix Bug: 'ReferenceError: elapsedTime is not defined' in this line: 'LK.showGameOver(elapsedTime + 's');' Line Number: 50
User prompt
If the game is over, display the time from the start
User prompt
Increase the probability of a meatItem appearing to 50% every 10 seconds.
User prompt
Increase the probability of meat items appearing to 20% every 40 seconds.
var elapsedTime = 0; var startTime = Date.now(); var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.createAsset('cloud', 'Cloud in the sky', 0.5, 0.5); cloudGraphics.scale.set(2); cloudGraphics.alpha = 0.8; self.move = function () { self.x -= 2; if (self.x + self.width / 2 < 0) { self.x = 2048 + self.width / 2; self.y = Math.random() * (2732 - self.height); } }; }); var Character = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.createAsset('character', 'Main character', .5, .5); characterGraphics.scale.set(1.5); self.velocityY = 0; self.jump = function () { self.velocityY = -25; }; self.fall = function () { self.velocityY += 1.2; self.y += self.velocityY; if (self.y > 2732 - self.height / 2 || self.y < self.height / 2) { LK.showGameOver(); } }; }); var Castle = Container.expand(function () { var self = Container.call(this); var castleGraphics = self.createAsset('castle', 'Castle obstacle', .5, .5); castleGraphics.scale.set(2.5); self.move = function () { self.x -= elapsedTime > 120 ? 8 : 5; }; }); var EnhancedCastle = Container.expand(function () { var self = Container.call(this); var castleGraphics = self.createAsset('castle', 'Enhanced Castle obstacle', .5, .5); castleGraphics.scale.set(3.5); self.move = function () { self.x -= elapsedTime > 120 ? 10 : 5; }; }); var Game = Container.expand(function () { var self = Container.call(this); var clouds = []; for (var i = 0; i < 5; i++) { var cloud = new Cloud(); cloud.x = Math.random() * 2048; cloud.y = Math.random() * (2732 - cloud.height); clouds.push(cloud); self.addChild(cloud); } LK.on('tick', function () { for (var i = 0; i < clouds.length; i++) { clouds[i].move(); } }); LK.stageContainer.setBackgroundColor(0x87CEEB); var character = self.addChild(new Character()); var castles = []; character.x = 2048 / 2; character.y = 2732 / 2; var timerTxt = new Text2('0:00', { size: 150, fill: "#ffffff" }); timerTxt.anchor.set(1, 0); LK.gui.topRight.addChild(timerTxt); stage.on('down', function (obj) { character.jump(); }); LK.on('tick', function () { character.fall(); for (var i = 0; i < castles.length; i++) { castles[i].move(); if (castles[i].x + castles[i].width / 2 < 0) { castles[i].destroy(); castles.splice(i, 1); } else if (character.intersects(castles[i])) { LK.showGameOver(); } } elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2); timerTxt.setText(elapsedTime + 's'); if (elapsedTime > 180) { LK.showGameOver(); } else if (elapsedTime > 60) { if (LK.ticks % 60 == 0) { var newCastle = new EnhancedCastle(); newCastle.x = 2048 + newCastle.width / 2; newCastle.y = Math.random() * (2732 - newCastle.height); castles.push(newCastle); self.addChild(newCastle); } } else { if (LK.ticks % 80 == 0) { var newCastle = new Castle(); newCastle.x = 2048 + newCastle.width / 2; newCastle.y = Math.random() * (2732 - newCastle.height); castles.push(newCastle); self.addChild(newCastle); } } }); });
===================================================================
--- original.js
+++ change.js
@@ -86,9 +86,11 @@
}
}
elapsedTime = ((Date.now() - startTime) / 1000).toFixed(2);
timerTxt.setText(elapsedTime + 's');
- if (elapsedTime > 60) {
+ if (elapsedTime > 180) {
+ LK.showGameOver();
+ } else if (elapsedTime > 60) {
if (LK.ticks % 60 == 0) {
var newCastle = new EnhancedCastle();
newCastle.x = 2048 + newCastle.width / 2;
newCastle.y = Math.random() * (2732 - newCastle.height);
Flying, Cute black cat with blue eyes. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Golden star. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cloud. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Meat on the bone. Dot picture. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.