User prompt
when the monster touches the hero the game should end
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: 225
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'monster.update();' Line Number: 157
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'monster.update();' Line Number: 157
User prompt
have the monster not appear in the game until 1 second after the game has started
User prompt
at the start of the game the hero gets 3 seconds of invincibility
User prompt
If the monster touches the hero end the game
User prompt
when the success popup shows up we need to pause the game
User prompt
the popup that says Success needs to show up on top of every other object on the screen
User prompt
when the hero comes into contact with the exit object show a popup in the middle of the visible screen that says "SUCCESS!"
User prompt
once the hero comes into contact with the obstacle create an exit object in the middle of the visible window
User prompt
when the hero touches the obstacle move it to the bottom left corner of the visible screen
User prompt
change the opacity of the black text background so it is fully opaque .
Code edit (1 edits merged)
Please save this source code
User prompt
Give the instruction text lines a black background color
User prompt
make all of the instruction text bright yellow color
Code edit (4 edits merged)
Please save this source code
User prompt
Add another text line to the instructions that says "Use propulsion orbs to get around. Grab them to use them again."
Code edit (2 edits merged)
Please save this source code
User prompt
if the monster touches the hero then end the game
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: instructions is not defined' in or related to this line: 'instructions.destroy();' Line Number: 169
User prompt
have the instruction text be wrapped onto three separate lines
User prompt
have the instructions and play button occur before the monster starts moving
/**** * 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(); 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.center.addChild(LK.showPopup('SUCCESS!', { x: 2048 / 2, y: 2732 / 2 })); } monster.update(); if (hero.intersects(monster)) { 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
@@ -46,9 +46,8 @@
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
- self.invincibilityTicks = 180;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
if (self.x < 0 || self.x > 2048) {
@@ -56,11 +55,8 @@
}
if (self.y < 0 || self.y > 2732) {
self.speedY *= -1;
}
- if (self.invincibilityTicks > 0) {
- self.invincibilityTicks--;
- }
};
});
var Monster = Container.expand(function () {
var self = Container.call(this);
@@ -75,11 +71,8 @@
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;
- if (hero.intersects(self) && hero.invincibilityTicks <= 0) {
- LK.showGameOver();
- }
}
};
});
var Obstacle = Container.expand(function () {
@@ -117,15 +110,12 @@
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 / 2;
hero.visible = false;
-var monster;
-LK.setTimeout(function () {
- monster = game.addChild(new Monster());
- monster.x = 2048 / 2;
- monster.y = 0;
- monster.visible = false;
-}, 1000);
+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 () {
@@ -142,11 +132,9 @@
x: 2048 / 2,
y: 2732 / 2
}));
}
- if (monster && monster.update) {
- monster.update();
- }
+ monster.update();
if (hero.intersects(monster)) {
LK.showGameOver();
}
var bulletsToRemove = [];
@@ -210,11 +198,9 @@
instructions2.destroy();
instructions3.destroy();
instructions4.destroy();
hero.visible = true;
- if (monster) {
- monster.visible = true;
- }
+ monster.visible = true;
});
game.on('down', function (obj) {
if (hero.visible && bullets.length < 12) {
var event = obj.event;
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.