User prompt
Make the shields have 10 health
User prompt
Make the fast aliens not count towards finishing the level
User prompt
Make it so there are fast aliens that zoom past the screen every 5 seconds and if you hit them you get 50 score
User prompt
Now can you make the player ship much much much much bigger
User prompt
Make the shields WAY smaller
User prompt
Can you make the shields and the player ship much much much much much much much bigger. They are too small
User prompt
Make it so you can shoot through the shields
User prompt
Make it so after every level completed a power up spawns on either side of you and you can drive on it to collect it. The power up will give you 1 extra life
User prompt
Make the first level have 1 row of aliens, level 2 have 2 rows, level 3 has 3 rows , level4 has 4 rows and level 5 has 5 rows
User prompt
Make the player ship Much much much much bigger
User prompt
Make it a modern style, with the player ship much much much larger
User prompt
This is perfect
User prompt
Make the bullets huge
User prompt
Make the alien hit boxes larger
User prompt
Make a boss alien that takes 10 shots to defeat and have it spawn in the back row of the aliens after 10 are killed
User prompt
Make the shields smaller
User prompt
Make the player ship much much bigger and raise the shields
User prompt
Make everything much bigger
User prompt
Make the aliens shoot every 5 seconds
User prompt
Make the aliens shoot an explosive bullet every 10 shots that can do 2 damage to the barriers instead of 1
User prompt
Make it so every 2 seconds you shoot a bullet
User prompt
Make the aliens slightly larger ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Cosmic Invaders: Alien Defense
Initial prompt
I want to make an alien shooter game
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Alien = Container.expand(function () { var self = Container.call(this); var alienGraphics = self.attachAsset('alien', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.4, scaleY: 1.4 }); self.width = alienGraphics.width; self.height = alienGraphics.height; self.active = true; self.points = 10; self.canShoot = true; // Add a subtle pulsing animation to the aliens tween(alienGraphics, { scaleX: 1.5, scaleY: 1.5 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(alienGraphics, { scaleX: 1.4, scaleY: 1.4 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { if (self.active) { // Repeat the animation if alien is still active tween(alienGraphics, { scaleX: 1.5, scaleY: 1.5 }, { duration: 1000, easing: tween.easeInOut }); } } }); } }); self.hit = function () { if (self.active) { self.active = false; LK.getSound('alienExplode').play(); LK.effects.flashObject(self, 0xffffff, 100); tween(self, { alpha: 0 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); return self.points; } return 0; }; return self; }); var AlienBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('alienBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.active = true; self.width = bulletGraphics.width; self.height = bulletGraphics.height; self.update = function () { self.y += self.speed; if (self.y > 2800) { self.active = false; } }; return self; }); var PlayerBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('playerBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -15; self.active = true; self.width = bulletGraphics.width; self.height = bulletGraphics.height; self.update = function () { self.y += self.speed; if (self.y < -50) { self.active = false; } }; return self; }); var PlayerShip = Container.expand(function () { var self = Container.call(this); var shipGraphics = self.attachAsset('playerShip', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 12; self.lives = 3; self.hasShield = false; self.multiShot = false; self.width = shipGraphics.width; self.height = shipGraphics.height; self.shield = self.attachAsset('shield', { anchorX: 0.5, anchorY: 0.5, y: 10, alpha: 0 }); self.activateShield = function () { self.hasShield = true; self.shield.alpha = 0.7; }; self.deactivateShield = function () { self.hasShield = false; self.shield.alpha = 0; }; self.hit = function () { if (self.hasShield) { self.deactivateShield(); return false; } else { LK.getSound('playerHit').play(); self.lives--; LK.effects.flashObject(self, 0xff0000, 500); return true; } }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.type = Math.floor(Math.random() * 3); // 0: shield, 1: multishot, 2: extra life self.speed = 5; self.active = true; self.width = powerUpGraphics.width; self.height = powerUpGraphics.height; // Change color based on type if (self.type === 0) { powerUpGraphics.tint = 0x9b59b6; // Shield - purple } else if (self.type === 1) { powerUpGraphics.tint = 0xf39c12; // Multishot - orange } else { powerUpGraphics.tint = 0x2ecc71; // Extra life - green } self.update = function () { self.y += self.speed; if (self.y > 2800) { self.active = false; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Game state variables var playerShip; var playerBullets = []; var aliens = []; var alienBullets = []; var powerUps = []; var shields = []; var gameActive = true; var score = 0; var level = 1; var alienDirection = 1; // 1 = right, -1 = left var alienMoveSpeed = 1; var alienDropAmount = 40; var alienShootChance = 0.01; var powerUpChance = 0.1; var lastShootTime = 0; var shootCooldown = 300; // ms var multiShotTimer = 0; var gameWidth = 2048; var gameHeight = 2732; // UI elements var scoreTxt; var levelTxt; var livesTxt; // Initialize game function initGame() { // Reset game state playerBullets = []; aliens = []; alienBullets = []; powerUps = []; shields = []; gameActive = true; score = 0; level = 1; alienDirection = 1; alienMoveSpeed = 1; alienShootChance = 0.01; multiShotTimer = 0; // Set score LK.setScore(0); // Create player ship playerShip = new PlayerShip(); playerShip.x = gameWidth / 2; playerShip.y = gameHeight - 150; game.addChild(playerShip); // Create shields createShields(); // Create UI createUI(); // Create aliens for first level createAlienWave(); // Play background music LK.playMusic('backgroundMusic'); } function createUI() { // Score text scoreTxt = new Text2('Score: 0', { size: 70, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(scoreTxt); scoreTxt.x = 120; // Keep away from the top left menu area // Level text levelTxt = new Text2('Level: 1', { size: 70, fill: 0xFFFFFF }); levelTxt.anchor.set(0.5, 0); LK.gui.top.addChild(levelTxt); // Lives text livesTxt = new Text2('Lives: 3', { size: 70, fill: 0xFFFFFF }); livesTxt.anchor.set(1, 0); LK.gui.topRight.addChild(livesTxt); } function createShields() { // Create 4 shields across the bottom var shieldCount = 4; var shieldSpacing = gameWidth / (shieldCount + 1); for (var i = 0; i < shieldCount; i++) { var shield = game.addChild(LK.getAsset('shield', { anchorX: 0.5, anchorY: 0.5 })); shield.x = shieldSpacing * (i + 1); shield.y = gameHeight - 300; shield.health = 3; shields.push(shield); } } function createAlienWave() { // Clear any remaining aliens for (var i = aliens.length - 1; i >= 0; i--) { aliens[i].destroy(); } aliens = []; // Increase difficulty with level alienMoveSpeed = 1 + level * 0.5; alienShootChance = 0.01 + level * 0.005; // Create alien grid var rows = 3 + Math.min(level, 3); // Max 6 rows var cols = 6 + Math.min(level, 4); // Max 10 columns var alienWidth = 140; // Increased width to account for larger aliens var alienHeight = 112; // Increased height to account for larger aliens var startX = (gameWidth - cols * alienWidth) / 2 + alienWidth / 2; var startY = 200; for (var row = 0; row < rows; row++) { for (var col = 0; col < cols; col++) { var alien = new Alien(); alien.x = startX + col * alienWidth; alien.y = startY + row * alienHeight; alien.row = row; alien.col = col; alien.points = (rows - row) * 10; // More points for aliens at the top game.addChild(alien); aliens.push(alien); } } } function playerShoot() { var now = Date.now(); if (now - lastShootTime < shootCooldown) { return; } lastShootTime = now; // Create bullet var bullet = new PlayerBullet(); bullet.x = playerShip.x; bullet.y = playerShip.y - playerShip.height / 2; game.addChild(bullet); playerBullets.push(bullet); // If player has multishot, create additional bullets if (playerShip.multiShot) { for (var i = -1; i <= 1; i += 2) { var sideBullet = new PlayerBullet(); sideBullet.x = playerShip.x + i * 20; sideBullet.y = playerShip.y - playerShip.height / 2; game.addChild(sideBullet); playerBullets.push(sideBullet); } } LK.getSound('playerShoot').play(); } function alienShoot() { // Find shooting aliens (bottom row of each column) var shootingAliens = []; var colMap = {}; for (var i = 0; i < aliens.length; i++) { var alien = aliens[i]; if (!alien.active) { continue; } // If this alien is lower than the current lowest in its column, it becomes the shooter if (!colMap[alien.col] || alien.row > colMap[alien.col].row) { colMap[alien.col] = alien; } } // Get all bottom aliens for (var col in colMap) { shootingAliens.push(colMap[col]); } // Randomly choose aliens to shoot based on difficulty for (var i = 0; i < shootingAliens.length; i++) { if (Math.random() < alienShootChance) { var shooter = shootingAliens[i]; var bullet = new AlienBullet(); bullet.x = shooter.x; bullet.y = shooter.y + shooter.height / 2; game.addChild(bullet); alienBullets.push(bullet); } } } function checkAlienMovement() { if (aliens.length === 0) { return; } var moveDown = false; var minX = gameWidth; var maxX = 0; // Find leftmost and rightmost aliens for (var i = 0; i < aliens.length; i++) { var alien = aliens[i]; if (alien.active) { minX = Math.min(minX, alien.x); maxX = Math.max(maxX, alien.x); } } // Check if aliens need to change direction if (maxX > gameWidth - 50 && alienDirection > 0 || minX < 50 && alienDirection < 0) { alienDirection *= -1; moveDown = true; } // Move aliens for (var i = 0; i < aliens.length; i++) { var alien = aliens[i]; if (alien.active) { alien.x += alienDirection * alienMoveSpeed; if (moveDown) { alien.y += alienDropAmount; // Check if aliens reached the bottom (game over condition) if (alien.y > gameHeight - 200) { gameOver(); return; } } } } } function spawnPowerUp(x, y) { if (Math.random() < powerUpChance) { var powerUp = new PowerUp(); powerUp.x = x; powerUp.y = y; game.addChild(powerUp); powerUps.push(powerUp); } } function checkCollisions() { // Player bullets vs aliens for (var i = playerBullets.length - 1; i >= 0; i--) { var bullet = playerBullets[i]; if (!bullet.active) { bullet.destroy(); playerBullets.splice(i, 1); continue; } var bulletHit = false; // Check against aliens for (var j = 0; j < aliens.length; j++) { var alien = aliens[j]; if (alien.active && bullet.intersects(alien)) { // Add points var pointsEarned = alien.hit(); score += pointsEarned; LK.setScore(score); scoreTxt.setText('Score: ' + score); // Chance to spawn power up spawnPowerUp(alien.x, alien.y); // Remove alien from array if no longer active if (!alien.active) { aliens.splice(j, 1); } // Remove bullet bullet.destroy(); playerBullets.splice(i, 1); bulletHit = true; break; } } // If already hit an alien, skip further checks if (bulletHit) { continue; } // Check against shields for shield damage for (var j = 0; j < shields.length; j++) { var shield = shields[j]; if (shield.health > 0 && bullet.intersects(shield)) { shield.health--; shield.alpha = shield.health / 3; if (shield.health <= 0) { shield.alpha = 0; } bullet.destroy(); playerBullets.splice(i, 1); break; } } } // Alien bullets vs player for (var i = alienBullets.length - 1; i >= 0; i--) { var bullet = alienBullets[i]; if (!bullet.active) { bullet.destroy(); alienBullets.splice(i, 1); continue; } // Check against player if (bullet.intersects(playerShip)) { var playerDamaged = playerShip.hit(); // Update lives display livesTxt.setText('Lives: ' + playerShip.lives); // Check for game over if (playerShip.lives <= 0) { gameOver(); } bullet.destroy(); alienBullets.splice(i, 1); continue; } // Check against shields for (var j = 0; j < shields.length; j++) { var shield = shields[j]; if (shield.health > 0 && bullet.intersects(shield)) { shield.health--; shield.alpha = shield.health / 3; if (shield.health <= 0) { shield.alpha = 0; } bullet.destroy(); alienBullets.splice(i, 1); break; } } } // Power-ups vs player for (var i = powerUps.length - 1; i >= 0; i--) { var powerUp = powerUps[i]; if (!powerUp.active) { powerUp.destroy(); powerUps.splice(i, 1); continue; } if (powerUp.intersects(playerShip)) { LK.getSound('powerUpCollect').play(); // Apply power-up effect if (powerUp.type === 0) { // Shield playerShip.activateShield(); } else if (powerUp.type === 1) { // Multi-shot playerShip.multiShot = true; multiShotTimer = 300; // Duration in ticks (5 seconds at 60fps) } else { // Extra life playerShip.lives++; livesTxt.setText('Lives: ' + playerShip.lives); } powerUp.destroy(); powerUps.splice(i, 1); } } } function checkLevelComplete() { if (aliens.length === 0) { level++; levelTxt.setText('Level: ' + level); createAlienWave(); } } function gameOver() { gameActive = false; LK.effects.flashScreen(0xff0000, 1000); LK.stopMusic(); LK.showGameOver(); } // Touch controls var touchX = null; game.down = function (x, y, obj) { touchX = x; playerShoot(); }; game.up = function (x, y, obj) { touchX = null; }; game.move = function (x, y, obj) { if (touchX !== null) { touchX = x; } }; // Game update loop game.update = function () { if (!gameActive) { return; } // Process player movement from touch if (touchX !== null) { // Move player toward touch position var moveDir = touchX > playerShip.x ? 1 : -1; if (Math.abs(touchX - playerShip.x) > 5) { playerShip.x += moveDir * playerShip.speed; } // Keep player in bounds if (playerShip.x < playerShip.width / 2) { playerShip.x = playerShip.width / 2; } if (playerShip.x > gameWidth - playerShip.width / 2) { playerShip.x = gameWidth - playerShip.width / 2; } } // Update multishot timer if (playerShip.multiShot) { multiShotTimer--; if (multiShotTimer <= 0) { playerShip.multiShot = false; } } // Update game objects checkAlienMovement(); // Alien shooting if (LK.ticks % 60 === 0) { // Check every second alienShoot(); } // Automatic player shooting every 2 seconds (120 ticks at 60fps) if (LK.ticks % 120 === 0) { playerShoot(); } // Update bullets for (var i = 0; i < playerBullets.length; i++) { playerBullets[i].update(); } for (var i = 0; i < alienBullets.length; i++) { alienBullets[i].update(); } // Update power-ups for (var i = 0; i < powerUps.length; i++) { powerUps[i].update(); } // Check collisions checkCollisions(); // Check if level is complete checkLevelComplete(); }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -578,8 +578,12 @@
if (LK.ticks % 60 === 0) {
// Check every second
alienShoot();
}
+ // Automatic player shooting every 2 seconds (120 ticks at 60fps)
+ if (LK.ticks % 120 === 0) {
+ playerShoot();
+ }
// Update bullets
for (var i = 0; i < playerBullets.length; i++) {
playerBullets[i].update();
}
Steel beam. In-Game asset. 2d. High contrast. No shadows
Bullet. In-Game asset. 2d. High contrast. No shadows
Military Tank. In-Game asset. 2d. High contrast. No shadows
Medkit. In-Game asset. 2d. High contrast. No shadows
Blue alien in a UFO, he’s mad and his body is inside the ufo. In-Game asset. 2d. High contrast. No shadows