User prompt
if the hero location gets within 50 of the exit after the obstacle is intersected tell the player they have won the game
User prompt
1 second after the hero comes in contact with the obstacle begin tracking the location of the exit object and updating it every tick
User prompt
Please fix the bug: 'ReferenceError: monsterLocationText is not defined' in or related to this line: 'monsterLocationText.setText('Monster Location: (' + Math.round(monster.x) + ', ' + Math.round(monster.y) + ')');' Line Number: 232
User prompt
Please fix the bug: 'ReferenceError: monsterLocationText is not defined' in or related to this line: 'monsterLocationText.setText('Monster Location: (' + Math.round(monster.x) + ', ' + Math.round(monster.y) + ')');' Line Number: 150
User prompt
Please fix the bug: 'ReferenceError: heroLocationText is not defined' in or related to this line: 'heroLocationText.setText('Hero Location: (' + Math.round(hero.x) + ', ' + Math.round(hero.y) + ')');' Line Number: 134
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'if (Math.abs(hero.x - exit.x) <= 200 && Math.abs(hero.y - exit.y) <= 200) {' Line Number: 108
User prompt
when the hero location is closer than 200 to the location of the exit object then tell they user that they have one the game
User prompt
Please fix the bug: 'Uncaught ReferenceError: exit is not defined' in or related to this line: 'if (exit && Math.abs(hero.x - exit.x) <= 100 && Math.abs(hero.y - exit.y) <= 100) {' Line Number: 108
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'if (Math.abs(hero.x - exit.x) <= 100 && Math.abs(hero.y - exit.y) <= 100) {' Line Number: 108
User prompt
say that the player has won the game when the hero location is within 100 of the exit location
User prompt
remove the section of the code that involves when the hero intersects the exit
User prompt
Please fix the bug: 'ReferenceError: monsterLocationText is not defined' in or related to this line: 'monsterLocationText.setText('Monster Location: (' + Math.round(monster.x) + ', ' + Math.round(monster.y) + ')');' Line Number: 155
User prompt
Please fix the bug: 'ReferenceError: monsterLocationText is not defined' in or related to this line: 'monsterLocationText.setText('Monster Location: (' + Math.round(monster.x) + ', ' + Math.round(monster.y) + ')');' Line Number: 156
User prompt
Please fix the bug: 'ReferenceError: heroLocationText is not defined' in or related to this line: 'heroLocationText.setText('Hero Location: (' + Math.round(hero.x) + ', ' + Math.round(hero.y) + ')');' Line Number: 134
User prompt
Please fix the bug: 'ReferenceError: heroLocationText is not defined' in or related to this line: 'heroLocationText.setText('Hero Location: (' + Math.round(hero.x) + ', ' + Math.round(hero.y) + ')');' Line Number: 134
User prompt
hide the hero and monster location text boxes
Code edit (1 edits merged)
Please save this source code
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
/**** * 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 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; LK.setTimeout(function () { exitLocationText = new Text2('Exit Location: (' + Math.round(exit.x) + ', ' + Math.round(exit.y) + ')', { size: 50, fill: '#ffffff' }); exitLocationText.anchor.set(1, 1); LK.gui.bottomRight.addChild(exitLocationText); }, 1000); } var exitLocationText; var dx = hero.x - exit.x; var dy = hero.y - exit.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance <= 50) { LK.gui.top.addChild(LK.showPopup('SUCCESS!', { x: 2048 / 2, y: 2732 / 2 })); LK.showGameOver(); } if (exitLocationText) { exitLocationText.setText('Exit Location: (' + Math.round(exit.x) + ', ' + Math.round(exit.y) + ')'); } monster.update(); if (Math.abs(hero.x - monster.x) <= 225 && Math.abs(hero.y - monster.y) <= 225) { 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)); // 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
@@ -126,17 +126,22 @@
obstacle.y = 2732;
var exit = game.addChild(new Exit());
exit.x = 2048 / 2;
exit.y = 2732 / 2;
+ LK.setTimeout(function () {
+ exitLocationText = new Text2('Exit Location: (' + Math.round(exit.x) + ', ' + Math.round(exit.y) + ')', {
+ size: 50,
+ fill: '#ffffff'
+ });
+ exitLocationText.anchor.set(1, 1);
+ LK.gui.bottomRight.addChild(exitLocationText);
+ }, 1000);
}
var exitLocationText;
- if (hero.intersects(exit)) {
- exitLocationText = new Text2('Exit Location: (' + Math.round(exit.x) + ', ' + Math.round(exit.y) + ')', {
- size: 50,
- fill: '#ffffff'
- });
- exitLocationText.anchor.set(1, 1);
- LK.gui.bottomRight.addChild(exitLocationText);
+ var dx = hero.x - exit.x;
+ var dy = hero.y - exit.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance <= 50) {
LK.gui.top.addChild(LK.showPopup('SUCCESS!', {
x: 2048 / 2,
y: 2732 / 2
}));
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.