User prompt
show how many bullets are left in the bottom right of the screen
User prompt
Make there be a limit of bullets that can be fired before the ship has to reload
User prompt
when a bullet hits the enemies, make a smaller explosion appear where they collided
User prompt
make the hero continue to shoot bullets
User prompt
make the enemies fire their own bullets
User prompt
make the enemies move from side to side while avoiding the asteroids
User prompt
Make the asteroids rotate and move faster
User prompt
when the hero collides with an asteroid, the hero vanishes off the screen
User prompt
Delay the game over trigger so that it appears 3 seconds after the hero dies
User prompt
If the hero collides with an asteroid make an explosion appear where they met
User prompt
move the hero further upwards
User prompt
Increase the speed of the asteroids
User prompt
Make the hero only be able to move from side to side
User prompt
rotate the bullets 45 degrees to the right
User prompt
rotate the enemies 90 degrees to the left
User prompt
rotate the enemies by 45 degrees to the right
User prompt
make the asteroids continuously rotate
User prompt
make the enemies move from left to right in random patterns while slowly moving downwards
User prompt
Please fix the bug: 'ReferenceError: enemyBullets is not defined' in or related to this line: 'for (var m = enemyBullets.length - 1; m >= 0; m--) {' Line Number: 180
User prompt
make the enemies fire bullets at the hero
User prompt
make the enemies fire bullets at the hero
Initial prompt
Up down space shooter game
/**** * Classes ****/ // Asteroid class var Asteroid = Container.expand(function () { var self = Container.call(this); var asteroidGraphics = self.attachAsset('asteroid', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; self.rotation += 0.01; // Add rotation to the asteroid if (self.y > 2732) { self.destroy(); } }; }); // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.update = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); } }; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); enemyGraphics.rotation = 0.785398; // Rotate by 45 degrees self.speed = 7; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { // Hero update logic }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize hero var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 200; // Initialize arrays for asteroids, enemies, and bullets var asteroids = []; var enemies = []; var bullets = []; // Function to handle hero movement function handleMove(x, y, obj) { hero.x = x; hero.y = y; } // Function to shoot bullets function shootBullet() { var bullet = new Bullet(); bullet.x = hero.x; bullet.y = hero.y - 50; bullets.push(bullet); game.addChild(bullet); } // Function to spawn asteroids function spawnAsteroid() { var asteroid = new Asteroid(); asteroid.x = Math.random() * 2048; asteroid.y = -50; asteroids.push(asteroid); game.addChild(asteroid); } // Function to spawn enemies function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = -50; enemies.push(enemy); game.addChild(enemy); } // Handle game move event game.move = handleMove; // Handle game down event to shoot bullets game.down = function (x, y, obj) { shootBullet(); }; // Update game logic game.update = function () { // Update asteroids for (var i = asteroids.length - 1; i >= 0; i--) { asteroids[i].update(); if (asteroids[i].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (enemies[j].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update bullets for (var k = bullets.length - 1; k >= 0; k--) { bullets[k].update(); for (var l = enemies.length - 1; l >= 0; l--) { if (bullets[k].intersects(enemies[l])) { bullets[k].destroy(); enemies[l].destroy(); bullets.splice(k, 1); enemies.splice(l, 1); break; } } } // Spawn asteroids and enemies periodically if (LK.ticks % 60 == 0) { spawnAsteroid(); } if (LK.ticks % 120 == 0) { spawnEnemy(); } };
===================================================================
--- original.js
+++ change.js
@@ -38,8 +38,9 @@
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
+ enemyGraphics.rotation = 0.785398; // Rotate by 45 degrees
self.speed = 7;
self.update = function () {
self.y += self.speed;
if (self.y > 2732) {
asteroid. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single enemy spaceship flying straight downwards viewed from above in colour. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single futuristic spaceship flying straight upwards viewed from above in colour without any background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single space torpedo flying upwards in colour. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
explosion in colour. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
large enemy space ship with massive cannons flying downwards viewed from on top in colour. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.