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
User prompt
add instructions and a play button to be pressed before the game starts
User prompt
create a start menu with a game explanation on it that goes away when the player touches the screen
User prompt
both the obstacle and the monster should spawn at the top center portion of the visible screen
Code edit (6 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: bullets is not defined' in or related to this line: 'for (var i = bullets.length - 1; i >= 0; i--) {' Line Number: 113
User prompt
Fix Bug: 'Uncaught ReferenceError: bulletCountText is not defined' in or related to this line: 'bulletCountText.anchor.set(1, 1);' Line Number: 130
User prompt
rename bullet to "Propulsion Orb" everywhere in the code
User prompt
add an obstacle to the game that randomly generates somewhere in the visible area
User prompt
add a monster to the game that slowly chases the hero
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
make the background 15% larger than it is now
User prompt
remove the border
User prompt
add the "background" image to the visible playing area
Code edit (1 edits merged)
Please save this source code
User prompt
the available bullets around the hero should be destroyed one tick after they are created
User prompt
show one bullet around the hero for each bullet currently available
Code edit (1 edits merged)
Please save this source code
User prompt
set the number of starting bullets to 8
User prompt
reduce the number of starting bullets by 1
User prompt
lower the number of starting bullets to 11
/**** * Classes ****/ 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 = 2732 / 3; 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 = 0; LK.on('tick', function () { hero.update(); monster.update(); 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('Survive alien attacks in a space container.', { size: 50, fill: '#ffffff' }); instructions1.anchor.set(0.5, 0.5); LK.gui.center.addChild(instructions1); var instructions2 = new Text2('Manage resources and outwit foes in Cosmic Container: Alien Ambush.', { size: 50, fill: '#ffffff' }); instructions2.anchor.set(0.5, 0.5); instructions2.y = instructions1.y + instructions1.height; LK.gui.center.addChild(instructions2); var instructions3 = new Text2('Tap the play button to start.', { size: 50, fill: '#ffffff' }); instructions3.anchor.set(0.5, 0.5); instructions3.y = instructions2.y + instructions2.height; LK.gui.center.addChild(instructions3); playButton.on('down', function (obj) { playButton.destroy(); instructions1.destroy(); instructions2.destroy(); instructions3.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
@@ -98,9 +98,9 @@
game.addChild(background);
// Create border around the visible area of the screen
var playButton = game.addChild(new PlayButton());
playButton.x = 2048 / 2;
-playButton.y = 2732 / 2;
+playButton.y = 2732 / 3;
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 / 2;
hero.visible = false;
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.