User prompt
make soft swipe control
User prompt
add background asset
User prompt
fix explode logic
User prompt
erase sea mine asset
User prompt
enemy two time shoot for there death
User prompt
make enemy bullet super fast shoot
User prompt
make enemy bullet fast moving
User prompt
Enemy bullets make it very fast
User prompt
reduce the number of enemy bullets to prevent game lag
User prompt
add animate explode fire in the sea when enemy is shot ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
erase animate explode
User prompt
Enemies can shoot in the direction the player is
User prompt
add explode ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
1 second bullet interval
User prompt
reduce bullet for lagging problem
Code edit (1 edits merged)
Please save this source code
User prompt
Deep Sea Hunter
Initial prompt
submarine shooter
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var EnemySubmarine = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemySubmarine', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.points = 10; self.update = function () { self.y += self.speed; }; return self; }); var SeaCreature = Container.expand(function () { var self = Container.call(this); var creatureGraphics = self.attachAsset('seaCreature', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.points = 20; self.update = function () { self.y += self.speed; // Add slight horizontal movement for more dynamic behavior self.x += Math.sin(LK.ticks * 0.05) * 0.5; }; return self; }); var SeaMine = Container.expand(function () { var self = Container.call(this); var mineGraphics = self.attachAsset('seaMine', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.points = 15; self.update = function () { self.y += self.speed; }; return self; }); var Submarine = Container.expand(function () { var self = Container.call(this); var submarineGraphics = self.attachAsset('submarine', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Torpedo = Container.expand(function () { var self = Container.call(this); var torpedoGraphics = self.attachAsset('torpedo', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000080 }); /**** * Game Code ****/ // Game variables var submarine; var torpedoes = []; var enemies = []; var dragNode = null; var spawnTimer = 0; var difficultyLevel = 1; var enemySpawnRate = 120; // Initial spawn rate (ticks between spawns) // Create submarine submarine = game.addChild(new Submarine()); submarine.x = 2048 / 2; submarine.y = 2732 - 200; // Create score display var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.setText(LK.getScore()); // Create high score display var highScore = storage.highScore || 0; var highScoreTxt = new Text2('Best: ' + highScore, { size: 60, fill: 0xFFFF00 }); highScoreTxt.anchor.set(1, 0); highScoreTxt.y = 120; LK.gui.topRight.addChild(highScoreTxt); // Handle submarine movement function handleMove(x, y, obj) { if (dragNode) { dragNode.x = Math.max(60, Math.min(2048 - 60, x)); dragNode.y = Math.max(100, Math.min(2732 - 100, y)); } } game.move = handleMove; game.down = function (x, y, obj) { dragNode = submarine; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; // Spawn enemy function function spawnEnemy() { var enemyType = Math.random(); var enemy; if (enemyType < 0.5) { enemy = new EnemySubmarine(); } else if (enemyType < 0.8) { enemy = new SeaMine(); } else { enemy = new SeaCreature(); } enemy.x = Math.random() * (2048 - 100) + 50; enemy.y = -50; enemy.lastY = enemy.y; enemy.lastIntersecting = false; enemies.push(enemy); game.addChild(enemy); } // Main game update loop game.update = function () { spawnTimer++; // Spawn enemies based on difficulty if (spawnTimer >= enemySpawnRate) { spawnEnemy(); spawnTimer = 0; // Increase difficulty over time if (LK.ticks % 1800 == 0) { // Every 30 seconds difficultyLevel++; enemySpawnRate = Math.max(30, enemySpawnRate - 10); } } // Fire torpedoes automatically if (LK.ticks % 40 == 0) { var torpedo = new Torpedo(); torpedo.x = submarine.x; torpedo.y = submarine.y - 40; torpedo.lastY = torpedo.y; torpedo.lastIntersecting = false; torpedoes.push(torpedo); game.addChild(torpedo); LK.getSound('torpedo_fire').play(); } // Update and check torpedoes for (var t = torpedoes.length - 1; t >= 0; t--) { var torpedo = torpedoes[t]; // Remove torpedoes that go off-screen if (torpedo.lastY >= -50 && torpedo.y < -50) { torpedo.destroy(); torpedoes.splice(t, 1); continue; } // Check torpedo-enemy collisions var torpedoHit = false; for (var e = enemies.length - 1; e >= 0; e--) { var enemy = enemies[e]; var currentIntersecting = torpedo.intersects(enemy); if (!torpedo.lastIntersecting && currentIntersecting) { // Torpedo hit enemy LK.setScore(LK.getScore() + enemy.points); scoreTxt.setText(LK.getScore()); // Create explosion effect LK.effects.flashObject(enemy, 0xFFFFFF, 500); LK.getSound('explosion').play(); // Remove both torpedo and enemy torpedo.destroy(); torpedoes.splice(t, 1); enemy.destroy(); enemies.splice(e, 1); torpedoHit = true; break; } } if (!torpedoHit) { torpedo.lastY = torpedo.y; torpedo.lastIntersecting = false; } } // Update and check enemies for (var e = enemies.length - 1; e >= 0; e--) { var enemy = enemies[e]; // Remove enemies that go off-screen if (enemy.lastY <= 2732 + 50 && enemy.y > 2732 + 50) { enemy.destroy(); enemies.splice(e, 1); continue; } // Check submarine-enemy collision var currentIntersecting = submarine.intersects(enemy); if (!enemy.lastIntersecting && currentIntersecting) { // Game Over LK.effects.flashScreen(0xFF0000, 1000); // Update high score if (LK.getScore() > highScore) { storage.highScore = LK.getScore(); } LK.showGameOver(); return; } enemy.lastY = enemy.y; enemy.lastIntersecting = currentIntersecting; } }; // Start background music LK.playMusic('underwater_ambient');
===================================================================
--- original.js
+++ change.js
@@ -155,9 +155,9 @@
enemySpawnRate = Math.max(30, enemySpawnRate - 10);
}
}
// Fire torpedoes automatically
- if (LK.ticks % 20 == 0) {
+ if (LK.ticks % 40 == 0) {
var torpedo = new Torpedo();
torpedo.x = submarine.x;
torpedo.y = submarine.y - 40;
torpedo.lastY = torpedo.y;
vertical top down blue king crab scifi submarine. In-Game asset. 2d. High contrast. No shadows
vertical top down red burn robotic octopus scifi war submarine. In-Game asset. 2d. High contrast. No shadows
vertical top down gray burn robotic turtle scifi war submarine. In-Game asset. 2d. High contrast. No shadows
top down image of gray sandy seabed. In-Game asset. 2d. High contrast. No shadows
blue electricity. In-Game asset. 2d. High contrast. No shadows
red electricity. In-Game asset. 2d. High contrast. No shadows