User prompt
when the monster location gets within 50 units of the hero location the game should end
User prompt
Please fix the bug: 'TypeError: LK.showPopup is not a function' in or related to this line: 'LK.gui.top.addChild(LK.showPopup('GAME OVER!', {' Line Number: 162
User prompt
Please fix the bug: 'TypeError: LK.showPopup is not a function' in or related to this line: 'LK.gui.top.addChild(LK.showPopup('GAME OVER!', {' Line Number: 162
User prompt
when the monster touches the hero the game should end
User prompt
the monster location needs to update every tick based
User prompt
constantly show the monster location on the screen in a text box in located in the bottom left of the visible screen
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'height')' in or related to this line: 'monsterLocationText.y = heroLocationText.height + 50;' Line Number: 113
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'y')' in or related to this line: 'monsterLocationText.y = heroLocationText.y + heroLocationText.height;' Line Number: 113
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'height')' in or related to this line: 'monsterLocationText.y = heroLocationText.height + 50;' Line Number: 113
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'y')' in or related to this line: 'monsterLocationText.y = heroLocationText.y + heroLocationText.height;' Line Number: 113
User prompt
constantly show the monster location on the screen in a text box in located in the top left of the visible screen that is below the hero location text box
User prompt
constantly show the hero location on the screen in a text box in located in the top left of the visible screen
User prompt
the game should end when the hero touches the exit object
User prompt
make sure the Success text is on the top gui layer and that it will show up
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'visible')' in or related to this line: 'monster.visible = true;' Line Number: 220
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'visible')' in or related to this line: 'monster.visible = true;' Line Number: 220
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'monster.update();' Line Number: 150
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'monster.update();' Line Number: 150
User prompt
the monster should not be generated in the game until 2 seconds after the play button has been pressed
User prompt
the monster should not appear in the game until 2 seconds after the play button is pressed
Code edit (1 edits merged)
Please save this source code
User prompt
Ensure there's a delay or a proper transition state that allows the game over text to be visible to the player
User prompt
add " Sorry you Died again" to the game over text
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ var Exit = Container.expand(function () { var self = Container.call(this); var exitGraphics = self.attachAsset('exit', { anchorX: 0.5, anchorY: 0.5 }); }); var PlayButton = Container.expand(function () { var self = Container.call(this); var playButtonGraphics = self.attachAsset('playbutton', { anchorX: 0.5, anchorY: 0.5 }); }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.invulnerabilityTicks = 16; self.move = function () { self.x += self.speedX; self.y += self.speedY; if (self.x < 0 || self.x > 2048) { self.speedX *= -1; self.x = self.x < 0 ? 0 : 2048; } if (self.y < 0 || self.y > 2732) { self.speedY *= -1; self.y = self.y < 0 ? 0 : 2732; } if (self.invulnerabilityTicks > 0) { self.invulnerabilityTicks--; } }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 0; self.speedY = 0; self.update = function () { self.x += self.speedX; self.y += self.speedY; if (self.x < 0 || self.x > 2048) { self.speedX *= -1; } if (self.y < 0 || self.y > 2732) { self.speedY *= -1; } }; }); var Monster = Container.expand(function () { var self = Container.call(this); var monsterGraphics = self.attachAsset('monster', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.update = function () { if (hero.visible) { var dx = hero.x - self.x; var dy = hero.y - self.y; var magnitude = Math.sqrt(dx * dx + dy * dy); self.x += self.speed * dx / magnitude; self.y += self.speed * dy / magnitude; } }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Add the 'Background' image to the visible playing area var monsterLocationText = new Text2('', { size: 50, fill: '#ffffff' }); monsterLocationText.anchor.set(0, 1); LK.gui.bottomLeft.addChild(monsterLocationText); var heroLocationText = new Text2('', { size: 50, fill: '#ffffff' }); heroLocationText.anchor.set(0, 0); LK.gui.topLeft.addChild(heroLocationText); var background = LK.getAsset('Background', { anchorX: 0.1, anchorY: 0.1, width: 2048 * 1.25, height: 2732 * 1.25, x: 0, y: 0 }); game.addChild(background); // Create border around the visible area of the screen var playButton = game.addChild(new PlayButton()); playButton.x = 2048 / 2; playButton.y = 1200; var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 / 2; hero.visible = false; var monster = game.addChild(new Monster()); monster.x = 2048 / 2; monster.y = 0; monster.visible = false; var obstacle = game.addChild(new Obstacle()); obstacle.x = 2048 / 2; obstacle.y = 300; LK.on('tick', function () { hero.update(); heroLocationText.setText('Hero Location: (' + Math.round(hero.x) + ', ' + Math.round(hero.y) + ')'); if (hero.intersects(obstacle)) { obstacle.x = 0; obstacle.y = 2732; var exit = game.addChild(new Exit()); exit.x = 2048 / 2; exit.y = 2732 / 2; } if (hero.intersects(exit)) { LK.gui.top.addChild(LK.showPopup('SUCCESS!', { x: 2048 / 2, y: 2732 / 2 })); LK.showGameOver(); } monster.update(); monsterLocationText.setText('Monster Location: (' + Math.round(monster.x) + ', ' + Math.round(monster.y) + ')'); if (Math.abs(hero.x - monster.x) <= 50 && Math.abs(hero.y - monster.y) <= 50) { LK.showGameOver(); } var bulletsToRemove = []; for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].move(); if (bullets[i].y < 0 || hero.intersects(bullets[i]) && bullets[i].invulnerabilityTicks <= 0) { bulletsToRemove.push(i); } } for (var i = 0; i < bulletsToRemove.length; i++) { bullets[bulletsToRemove[i]].destroy(); bullets.splice(bulletsToRemove[i], 1); } bulletCountText.setText('Propulsion Orbs: ' + (11 - bullets.length + 1)); }); var bullets = []; var bulletCountText = new Text2('Propulsion Orbs: 8', { size: 50, fill: '#ffffff' }); bulletCountText.anchor.set(1, 1); LK.gui.bottomRight.addChild(bulletCountText); var instructions1 = new Text2('Grab the green gift before the alien grabs you!', { size: 50, fill: '#FFFF00', background: '#000000', alpha: 1 }); instructions1.anchor.set(0.5, 0.5); LK.gui.center.addChild(instructions1); var instructions2 = new Text2('Tap screen to use propulsion orbs to get around.', { size: 50, fill: '#FFFF00', background: '#000000', alpha: 1 }); instructions2.anchor.set(0.5, 0.5); instructions2.y = instructions1.y + instructions1.height; LK.gui.center.addChild(instructions2); var instructions3 = new Text2(' Grab the bouncing orbs to use them again.', { size: 50, fill: '#FFFF00', background: '#000000', alpha: 1 }); instructions3.anchor.set(0.5, 0.5); instructions3.y = instructions2.y + instructions2.height; LK.gui.center.addChild(instructions3); var instructions4 = new Text2('Tap the play button to start.', { size: 50, fill: '#FFFF00', background: '#000000', alpha: 1 }); instructions4.anchor.set(0.5, 0.5); instructions4.y = instructions3.y + instructions3.height; LK.gui.center.addChild(instructions4); playButton.on('down', function (obj) { playButton.destroy(); instructions1.destroy(); instructions2.destroy(); instructions3.destroy(); instructions4.destroy(); hero.visible = true; monster.visible = true; }); game.on('down', function (obj) { if (hero.visible && bullets.length < 12) { var event = obj.event; var pos = event.getLocalPosition(game); var bullet = new Bullet(); bullet.x = hero.x; bullet.y = hero.y; var dx = pos.x - hero.x; var dy = pos.y - hero.y; var magnitude = Math.sqrt(dx * dx + dy * dy); bullet.speedX = bullet.speed * dx / magnitude; bullet.speedY = bullet.speed * dy / magnitude; bullets.push(bullet); game.addChild(bullet); bulletCountText.setText('Propulsion Orbs: ' + (12 - bullets.length)); monsterLocationText.setText('Monster Location: (' + Math.round(monster.x) + ', ' + Math.round(monster.y) + ')'); // Add velocity to the hero in opposite direction of the bullet hero.speedX += -bullet.speedX / 10; hero.speedY += -bullet.speedY / 10; } });
===================================================================
--- original.js
+++ change.js
@@ -140,15 +140,19 @@
exit.x = 2048 / 2;
exit.y = 2732 / 2;
}
if (hero.intersects(exit)) {
+ LK.gui.top.addChild(LK.showPopup('SUCCESS!', {
+ x: 2048 / 2,
+ y: 2732 / 2
+ }));
LK.showGameOver();
}
- if (hero.intersects(monster)) {
- LK.showGameOver();
- }
monster.update();
monsterLocationText.setText('Monster Location: (' + Math.round(monster.x) + ', ' + Math.round(monster.y) + ')');
+ if (Math.abs(hero.x - monster.x) <= 50 && Math.abs(hero.y - monster.y) <= 50) {
+ LK.showGameOver();
+ }
var bulletsToRemove = [];
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].move();
if (bullets[i].y < 0 || hero.intersects(bullets[i]) && bullets[i].invulnerabilityTicks <= 0) {
Create the top down view of what it would look to be inside of a very dark space ship's empty cargo bay.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a top down view of an astronaut in a bright yellow space suit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a round bright orange energy orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a scary space monster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a yellow Play button. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
show a bright green package. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create an escape hatch with a red exit sign on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.