User prompt
add a los angalos backround
User prompt
Add a wall that aliens can not come through but you can shoot them.
User prompt
add higher alien spawn rate
User prompt
add barier infront of comand center and give it 20 health
User prompt
make speed of aliens slower
User prompt
make a quarter of the aliens gaurd the comand center
User prompt
make ending screen when comand center is hit 25 time you win
User prompt
Make half of aliens go to side of player to try to kill them
User prompt
reduce amount of aliens spawning by a little
User prompt
spawn more aliens at the same time
User prompt
make aliens move towards player. If player gets hit by 3 aliens end game
User prompt
if comand base gets shot 25 times end game
Initial prompt
Battle: Los Angelos
/**** * Classes ****/ // Alien class representing enemy characters var Alien = Container.expand(function () { var self = Container.call(this); var alienGraphics = self.attachAsset('alien', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // Update logic for alien // Calculate the direction vector between the alien and the player var dx = hero.x - self.x; var dy = hero.y - self.y; var magnitude = Math.sqrt(dx * dx + dy * dy); // Normalize the direction vector dx /= magnitude; dy /= magnitude; // Move the alien towards the player if (Math.random() > 0.5) { self.x += dx * self.speed; } else { self.x += dx * self.speed * -1; // Make half of aliens go to side of player } self.y += dy * self.speed; }; }); // Bullet class for projectiles 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; }; }); // CommandBase class representing the target to destroy var CommandBase = Container.expand(function () { var self = Container.call(this); var baseGraphics = self.attachAsset('commandBase', { anchorX: 0.5, anchorY: 0.5 }); }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Hero class representing the player character 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 () { // Update logic for hero }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize game elements var hero = game.addChild(new Hero()); hero.x = 1024; hero.y = 2400; var commandBase = game.addChild(new CommandBase()); commandBase.x = 1024; commandBase.y = 200; var aliens = []; var bullets = []; var commandBaseHits = 0; // New variable to keep track of the number of times the command base has been shot var playerHits = 0; // New variable to keep track of the number of times the player has been hit by aliens // Function to handle movement function handleMove(x, y, obj) { hero.x = x; hero.y = y; } // Function to handle shooting function shoot() { var bullet = new Bullet(); bullet.x = hero.x; bullet.y = hero.y; bullets.push(bullet); game.addChild(bullet); } // Function to spawn aliens function spawnAlien() { for (var i = 0; i < 2; i++) { // Spawn 2 aliens at a time var alien = new Alien(); alien.x = Math.random() * 2048; alien.y = 0; aliens.push(alien); game.addChild(alien); } } // Game update loop game.update = function () { // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; bullet.update(); if (bullet.y < 0) { bullet.destroy(); bullets.splice(i, 1); } } // Update aliens for (var j = aliens.length - 1; j >= 0; j--) { var alien = aliens[j]; alien.update(); if (alien.y > 2732) { alien.destroy(); aliens.splice(j, 1); } } // Check for collisions for (var k = bullets.length - 1; k >= 0; k--) { var bullet = bullets[k]; for (var l = aliens.length - 1; l >= 0; l--) { var alien = aliens[l]; if (bullet.intersects(alien)) { bullet.destroy(); alien.destroy(); bullets.splice(k, 1); aliens.splice(l, 1); break; } } // Check if bullet hits command base if (bullet.intersects(commandBase)) { bullet.destroy(); bullets.splice(k, 1); commandBaseHits++; // Increment the commandBaseHits variable } } // Check if player has been hit by an alien for (var m = aliens.length - 1; m >= 0; m--) { var alien = aliens[m]; if (alien.intersects(hero)) { alien.destroy(); aliens.splice(m, 1); playerHits++; // Increment the playerHits variable break; } } // Check if command base has been shot 25 times if (commandBaseHits >= 25) { LK.showGameOver(); } // Check if player has been hit by 3 aliens if (playerHits >= 3) { LK.showGameOver(); } }; // Event listeners game.move = handleMove; game.down = function (x, y, obj) { shoot(); }; // Spawn aliens at intervals LK.setInterval(spawnAlien, 2000);
===================================================================
--- original.js
+++ change.js
@@ -18,9 +18,13 @@
// Normalize the direction vector
dx /= magnitude;
dy /= magnitude;
// Move the alien towards the player
- self.x += dx * self.speed;
+ if (Math.random() > 0.5) {
+ self.x += dx * self.speed;
+ } else {
+ self.x += dx * self.speed * -1; // Make half of aliens go to side of player
+ }
self.y += dy * self.speed;
};
});
// Bullet class for projectiles
a high tech alien command base. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a weaponazized alien. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a city that is wartorn and has many explosoins and brocken buildings. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows