User prompt
enemy one hit death
User prompt
release enemy bullet
User prompt
erase enemy bullet storm
User prompt
lower enemy bullet
User prompt
increase speed enemy bullet
User prompt
lower speed bullet release
User prompt
bullet automatic release when enemy appear
User prompt
loop enemy
User prompt
automatic bullet release
User prompt
lower enemy appear
User prompt
erase bullet storm
User prompt
more enemy bullets
User prompt
increase enemy bullet speed
User prompt
increase enemy power
User prompt
fix game bugs
User prompt
increase enemy speed
User prompt
enemy more speed
User prompt
more enemy appear
User prompt
erase score display
User prompt
make bullet storm release
User prompt
add 3X bullet player speed
User prompt
decrease enemy appear
User prompt
slow down enemy and enemy bullet speed
User prompt
decrease enemy and enemy bullet appear for stabilty frame in game
User prompt
erase auto shoot
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScore: 0 }); /**** * Classes ****/ var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 60; self.damage = 1; self.update = function () { // Auto-move player left and right self.y -= self.speed; // Auto-destroy bullets that go off screen if (self.y < -50) { self.destroy(); } }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.health = 1; self.speed = 1.5 + Math.random() * 0.5; // Further increase enemy movement speed self.value = 100; // score value self.canShoot = Math.random() < 0.5; // 50% of enemies can shoot self.lastShot = 0; self.fireRate = 2000 + Math.random() * 2000; // Random fire rate between 2-4 seconds // Create health bar self.healthBarBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5, y: -70 }); self.healthBar = self.attachAsset('healthBar', { anchorX: 0.5, anchorY: 0.5, y: -70 }); self.updateHealthBar = function () { var healthPercentage = self.health / 2; // 2 is max health self.healthBar.scaleX = healthPercentage; }; self.damage = function (amount) { self.health -= amount; self.updateHealthBar(); // Flash enemy when hit LK.effects.flashObject(self, 0xffffff, 200); if (self.health <= 0) { // Create explosion var explosion = new Explosion(); explosion.x = self.x; explosion.y = self.y; game.addChild(explosion); // Add score LK.setScore(LK.getScore() + self.value); // Remove from array and destroy self.destroy(); } }; self.shoot = function () { var bullet = new EnemyBullet(); bullet.x = self.x; bullet.y = self.y + 50; game.addChild(bullet); // Add to game's enemyBullets array enemyBullets.push(bullet); LK.getSound('enemyShoot').play(); }; self.update = function () { self.y += self.speed; // Move slightly left or right if (LK.ticks % 30 === 0) { // Increase frequency of movement self.x += (Math.random() - 0.5) * 150; // Increase movement range // Keep within bounds if (self.x < 100) { self.x = 100; } if (self.x > 2048 - 100) { self.x = 2048 - 100; } } // Shooting logic if (self.canShoot) { var now = Date.now(); if (now - self.lastShot > self.fireRate) { self.lastShot = now; self.shoot(); } } // Destroy if off screen if (self.y > 2732 + 100) { self.destroy(); } }; return self; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; // Slow down enemy bullet speed self.damage = 3; self.update = function () { self.y += self.speed; // Auto-destroy bullets that go off screen if (self.y > 2732 + 50) { self.destroy(); } }; return self; }); var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); // Play explosion sound LK.getSound('explosion').play(); // Animate explosion tween(explosionGraphics, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.maxHealth = 3; self.health = self.maxHealth; self.fireRate = 400; // ms between shots self.lastShot = 0; self.speed = 20; self.invulnerable = false; // Create health bar self.healthBarBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5, y: -80 }); self.healthBar = self.attachAsset('healthBar', { anchorX: 0.5, anchorY: 0.5, y: -80 }); self.updateHealthBar = function () { var healthPercentage = self.health / self.maxHealth; self.healthBar.scaleX = healthPercentage; }; self.damage = function (amount) { if (self.invulnerable) { return; } self.health -= amount; self.updateHealthBar(); LK.getSound('playerHit').play(); // Flash player when hit self.invulnerable = true; LK.effects.flashObject(self, 0xff0000, 1000); LK.setTimeout(function () { self.invulnerable = false; }, 1000); if (self.health <= 0) { // Create explosion var explosion = new Explosion(); explosion.x = self.x; explosion.y = self.y; game.addChild(explosion); // Game over LK.setTimeout(function () { LK.showGameOver(); }, 1000); self.visible = false; } }; self.shoot = function () { var now = Date.now(); if (now - self.lastShot < self.fireRate) { return; } self.lastShot = now; // Create a bullet storm by releasing multiple bullets in a spread pattern for (var i = -2; i <= 2; i++) { var bullet = new Bullet(); bullet.x = self.x + i * 20; // Spread bullets horizontally bullet.y = self.y - 50; game.addChild(bullet); // Add to game's bullets array bullets.push(bullet); } LK.getSound('playerShoot').play(); }; self.down = function (x, y, obj) { self.shoot(); // Trigger shooting when player is touched }; self.update = function () { // Manual player movement control if (gameActive) { // Movement logic will be handled in game.move } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background = LK.getAsset('nightSky', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(background); // Game variables var player; var bullets = []; var enemyBullets = []; var enemies = []; var powerUps = []; var waveNumber = 1; var enemiesInWave = 5 + waveNumber * 2; var lastEnemySpawn = 0; var enemySpawnRate = 2000; // Increase to 2 seconds between spawns for stability var waveDelay = 5000; // 5 seconds between waves var gameActive = true; var dragActive = false; // Setup GUI var waveTxt = new Text2('WAVE 1', { size: 80, fill: 0xFFFFFF }); waveTxt.anchor.set(0.5, 0); LK.gui.top.addChild(waveTxt); waveTxt.y = 50; // Initialize player player = new Player(); player.x = 2048 / 2; player.y = 2732 - 300; player.updateHealthBar(); game.addChild(player); // Start background music LK.playMusic('bgMusic', { fade: { start: 0, end: 0.6, duration: 1000 } }); // Touch/mouse handling var lastTapTime = 0; game.down = function (x, y, obj) { if (!gameActive) { return; } var currentTime = Date.now(); if (currentTime - lastTapTime < 300) { // Double-tap detected within 300ms player.speed = 20; // Resume player movement } lastTapTime = currentTime; if (gameActive) { player.shoot(); // Shoot when tapping } }; game.move = function (x, y, obj) { if (!gameActive || !player.visible) { return; } // Constrain player to game area if (x > 100 && x < 2048 - 100) { player.x = x; } if (y > 100 && y < 2732 - 100) { player.y = y; } }; game.up = function (x, y, obj) { dragActive = false; }; // Spawn enemies for current wave function spawnWave() { if (waveNumber > 100) { gameActive = false; updateHighScore(); LK.showYouWin(); return; } enemiesInWave = 10 + waveNumber * 3; // Increase the number of enemies per wave for more frequent enemy appearances waveTxt.setText('WAVE ' + waveNumber); // Show wave notification waveTxt.alpha = 1; tween(waveTxt, { alpha: 0 }, { duration: 2000, easing: tween.easeOut }); // Slightly increase enemy spawn rate with each wave enemySpawnRate = Math.max(1000, 1500 - waveNumber * 50); } // Spawn a single enemy function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * (2048 - 200) + 100; // Random position between 100 and (2048-100) enemy.y = -100; // Start above the screen enemy.updateHealthBar(); // Increase enemy health every few waves if (waveNumber > 3) { enemy.health += Math.floor(waveNumber / 3); enemy.updateHealthBar(); } // Increase enemy speed slightly with each wave enemy.speed += waveNumber * 0.1; game.addChild(enemy); enemies.push(enemy); enemiesInWave--; // Decrease the count of enemies to spawn in the current wave } // Save the high score if needed function updateHighScore() { var currentScore = LK.getScore(); if (currentScore > storage.highScore) { storage.highScore = currentScore; } } // Main game update loop game.update = function () { if (!gameActive) { return; } // Enemy spawning logic var now = Date.now(); if (enemies.length < enemiesInWave && now - lastEnemySpawn > enemySpawnRate) { lastEnemySpawn = now; spawnEnemy(); } // Wave transition logic if (enemies.length === 0 && enemiesInWave <= 0) { waveNumber++; if (waveNumber <= 100) { // Start next wave after delay LK.setTimeout(function () { spawnWave(); }, waveDelay); enemiesInWave = 5 + waveNumber * 2; // Reset for next wave } else { gameActive = false; updateHighScore(); LK.showYouWin(); } } // Bullet collision detection for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; // Check collision with each enemy for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (bullet.intersects(enemy)) { // Damage enemy enemy.damage(bullet.damage); // Remove bullet bullet.destroy(); bullets.splice(i, 1); // If enemy is destroyed, remove from array if (enemy.health <= 0) { enemies.splice(j, 1); enemiesInWave--; } break; // This bullet hit something, stop checking } } } // Enemy bullet collision with player if (player.visible) { for (var i = enemyBullets.length - 1; i >= 0; i--) { var bullet = enemyBullets[i]; if (bullet.intersects(player)) { // Damage player player.damage(bullet.damage); // Remove bullet bullet.destroy(); enemyBullets.splice(i, 1); // Check if game over if (player.health <= 0) { gameActive = false; updateHighScore(); } } // Check collision with player bullets for (var j = bullets.length - 1; j >= 0; j--) { var playerBullet = bullets[j]; if (bullet.intersects(playerBullet)) { // Create explosion at the collision point var explosion = new Explosion(); explosion.x = bullet.x; explosion.y = bullet.y; game.addChild(explosion); // Destroy both bullets bullet.destroy(); enemyBullets.splice(i, 1); playerBullet.destroy(); bullets.splice(j, 1); break; // Stop checking this bullet } } } // Enemy collision with player for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; if (enemy.intersects(player)) { // Damage player player.damage(1); // Damage enemy enemy.damage(1); // If enemy is destroyed, remove from array if (enemy.health <= 0) { enemies.splice(i, 1); enemiesInWave--; } // Check if game over if (player.health <= 0) { gameActive = false; updateHighScore(); } } } } // Clean up arrays (remove destroyed objects) bullets = bullets.filter(function (bullet) { return bullet.parent !== null; }); enemyBullets = enemyBullets.filter(function (bullet) { return bullet.parent !== null; }); enemies = enemies.filter(function (enemy) { return enemy.parent !== null; }); powerUps = powerUps.filter(function (powerUp) { return powerUp.parent !== null; }); }; // Start the first wave spawnWave();
===================================================================
--- original.js
+++ change.js
@@ -23,12 +23,8 @@
// Auto-destroy bullets that go off screen
if (self.y < -50) {
self.destroy();
}
- // Auto-destroy bullets that go off screen
- if (self.y < -50) {
- self.destroy();
- }
};
return self;
});
var Enemy = Container.expand(function () {
@@ -108,11 +104,8 @@
}
// Destroy if off screen
if (self.y > 2732 + 100) {
self.destroy();
- gameActive = false;
- updateHighScore();
- LK.showGameOver();
}
};
return self;
});
@@ -128,11 +121,8 @@
self.y += self.speed;
// Auto-destroy bullets that go off screen
if (self.y > 2732 + 50) {
self.destroy();
- gameActive = false;
- updateHighScore();
- LK.showGameOver();
}
};
return self;
});
@@ -305,9 +295,11 @@
// Double-tap detected within 300ms
player.speed = 20; // Resume player movement
}
lastTapTime = currentTime;
- player.shoot(); // Shoot when tapping
+ if (gameActive) {
+ player.shoot(); // Shoot when tapping
+ }
};
game.move = function (x, y, obj) {
if (!gameActive || !player.visible) {
return;
8 bit image city of newyork with black sky night. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
8 bit image black rocket with fire tail. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
8 bit front image blue red scifi police drone. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
fire explode with piece of black steel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
fire ball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows