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
User prompt
correct the code for concurrent modification when a bullet is added to inventory after it is destroyed by coming into contact with the hero
Code edit (1 edits merged)
Please save this source code
User prompt
add a bullet back into the available supply when a bullet is destroyed by coming into contact with the hero
Code edit (1 edits merged)
Please save this source code
User prompt
the first bullet cannot be destroyed for the first 3 ticks of its existence
User prompt
when a bullet comes into contact with the hero the bullet should be destroyed
Code edit (1 edits merged)
Please save this source code
User prompt
when the user clicks on the screen it should only consume one of the available bullets
User prompt
only one bullet should be fired when the user clicks on the screen
User prompt
when a bullet intersects with the hero add one additional unit to the number of bullets
User prompt
add the ability to detect when a bullet comes into close contact with the hero
Code edit (2 edits merged)
Please save this source code
User prompt
When a bullet hits the hero it should add one bullet back to the quantity available
User prompt
Show the number of bullets available as a permanent text field in the bottom right corner of the visible screen
/**** * Classes ****/ 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 = 8; 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; } }; }); /**** * 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: -100, anchorY: 0.0, width: 2048 * 1.15, height: 2732 * 1.15, x: 0, y: 0 }); game.addChild(background); // Create border around the visible area of the screen var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 / 2; LK.on('tick', function () { hero.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('Bullets: ' + (11 - bullets.length + 1)); }); var bullets = []; var bulletCountText = new Text2('Bullets: 8', { size: 50, fill: '#ffffff' }); bulletCountText.anchor.set(1, 1); LK.gui.bottomRight.addChild(bulletCountText); game.on('down', function (obj) { if (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('Bullets: ' + (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
@@ -56,9 +56,9 @@
* Game Code
****/
// Add the 'Background' image to the visible playing area
var background = LK.getAsset('Background', {
- anchorX: 0.0,
+ anchorX: -100,
anchorY: 0.0,
width: 2048 * 1.15,
height: 2732 * 1.15,
x: 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.