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
User prompt
lets limit the number of bullets that can be fired to 12
User prompt
the bullets should bounce off of all sides of the visible screen
User prompt
bullets and the hero should bounce off the visible area of the screen
User prompt
hero speed should be additive with each bullet fired
User prompt
the direction of the velocity added to the hero when a bullet is fired should be opposite of the direction the bullet is traveling
User prompt
the bullet should not have recoil, it should give velocity to the hero that does not stop
User prompt
begin moving the hero in the opposite direction a bullet is fired every time a bullet is fired
User prompt
the bullet should start from the location of the hero and go towards where the user touched the screen
User prompt
have the hero fire a bullet when ever the user touches the screen in the spot the user touched the screen
User prompt
Fix Bug: 'Uncaught TypeError: Graphics is not a constructor' in or related to this line: 'var border = new Graphics();' Line Number: 29
User prompt
take out the move function of the hero
Code edit (2 edits merged)
Please save this source code
User prompt
when the hero touches the edge of the visable screen it should bounce off of the that edge
Code edit (1 edits merged)
Please save this source code
User prompt
significantly increase velocity change amount after touching the screen
User prompt
have the game always look for the touch and continually adjust the velocity after the user touches the 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.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; } }; }); 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 ****/ // Create border around the visible area of the screen var border = LK.getAsset('border', { anchorX: 0.0, anchorY: 0.0, width: 2048, height: 2732, x: 0, y: 0 }); game.addChild(border); var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 / 2; LK.on('tick', function () { hero.update(); for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].move(); if (bullets[i].y < 0) { bullets[i].destroy(); bullets.splice(i, 1); } if (hero.intersects(bullets[i])) { bullets[i].destroy(); bullets.splice(i, 1); bulletCountText.setText('Bullets: ' + (12 - bullets.length)); } } }); var bullets = []; var bulletCountText = new Text2('Bullets: 12', { 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
@@ -72,10 +72,10 @@
bullets[i].destroy();
bullets.splice(i, 1);
}
if (hero.intersects(bullets[i])) {
- bullets.push(new Bullet());
- game.addChild(bullets[bullets.length + 1]);
+ bullets[i].destroy();
+ bullets.splice(i, 1);
bulletCountText.setText('Bullets: ' + (12 - bullets.length));
}
}
});
@@ -103,9 +103,6 @@
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;
- } else {
- // If there are no bullets left, do not create a new bullet
- return;
}
});
\ No newline at end of file
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.