User prompt
Add a round, there will be 5 rounds Round 1: Normal Monsters (15 Pieces) Round 2: Normal Monster and Big Monster (20 Pieces 15 Normal 5 Large) Round 3: Big Monster (15 pieces) Round 4:Big and King Monster (20 Pieces 15 Big 5 King) Round 5:King Monster (10 Pieces)
User prompt
I'm going to add one more monster (add assets to it) Name:King Monster Health:5 Damage:20
User prompt
Make Assets for the big monster
User prompt
I will add a new monster, it will take 10 lives, it must be wawes 2 times to kill (Name:Big monster)
User prompt
Let the monster take 5 lives
User prompt
Add lives (100 lives)
User prompt
Remove Score
User prompt
Make cooldown 1 second
User prompt
Add attack cooldown ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Wawes are so big
User prompt
It goes up to a certain point, when we click on it, it goes directly to that side (to infinity)
User prompt
No, when we click, it goes whichever way we clicked (from our ship to there)
User prompt
Let there be no waves around us, let it go directly to that side by clicking on a place
Code edit (1 edits merged)
Please save this source code
User prompt
Wave Defender
Initial prompt
It is a game that takes place at sea, we are ships and monsters are coming, we send waves to them by clicking and kill them)
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Monster = Container.expand(function () { var self = Container.call(this); var monsterGraphics = self.attachAsset('monster', { anchorX: 0.5, anchorY: 0.5 }); self.health = 1; self.speed = 2; self.damage = 10; self.targetX = 0; self.targetY = 0; self.update = function () { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } }; return self; }); var Ship = Container.expand(function () { var self = Container.call(this); var shipGraphics = self.attachAsset('ship', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; return self; }); var Wave = Container.expand(function () { var self = Container.call(this); var waveGraphics = self.attachAsset('wave', { anchorX: 0.5, anchorY: 0.5 }); self.damage = 1; self.maxRadius = 200; self.expansionSpeed = 8; self.currentRadius = 20; self.lifetime = 0; self.maxLifetime = 30; waveGraphics.alpha = 0.7; self.update = function () { self.lifetime++; if (self.currentRadius < self.maxRadius) { self.currentRadius += self.expansionSpeed; var scale = self.currentRadius / 20; waveGraphics.scaleX = scale; waveGraphics.scaleY = scale; } var alphaFactor = 1 - self.lifetime / self.maxLifetime; waveGraphics.alpha = Math.max(0, alphaFactor * 0.7); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x001133 }); /**** * Game Code ****/ var ship = game.addChild(new Ship()); ship.x = 2048 / 2; ship.y = 2732 / 2; var monsters = []; var waves = []; var monsterSpawnTimer = 0; var monsterSpawnRate = 120; var difficultyTimer = 0; var gameStarted = true; var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); function spawnMonster() { var monster = new Monster(); var side = Math.floor(Math.random() * 4); switch (side) { case 0: // Top monster.x = Math.random() * 2048; monster.y = -30; break; case 1: // Right monster.x = 2048 + 30; monster.y = Math.random() * 2732; break; case 2: // Bottom monster.x = Math.random() * 2048; monster.y = 2732 + 30; break; case 3: // Left monster.x = -30; monster.y = Math.random() * 2732; break; } monster.targetX = ship.x; monster.targetY = ship.y; monsters.push(monster); game.addChild(monster); } function createWave(x, y) { var wave = new Wave(); wave.x = x; wave.y = y; waves.push(wave); game.addChild(wave); LK.getSound('waveSound').play(); } function checkWaveMonsterCollisions() { for (var w = waves.length - 1; w >= 0; w--) { var wave = waves[w]; for (var m = monsters.length - 1; m >= 0; m--) { var monster = monsters[m]; var dx = wave.x - monster.x; var dy = wave.y - monster.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance <= wave.currentRadius) { monster.health -= wave.damage; if (monster.health <= 0) { LK.setScore(LK.getScore() + 10); scoreTxt.setText('Score: ' + LK.getScore()); LK.getSound('monsterHit').play(); monster.destroy(); monsters.splice(m, 1); } } } } } function checkMonsterShipCollisions() { for (var m = monsters.length - 1; m >= 0; m--) { var monster = monsters[m]; if (ship.intersects(monster)) { ship.health -= monster.damage; LK.getSound('shipHit').play(); LK.effects.flashScreen(0xff0000, 500); monster.destroy(); monsters.splice(m, 1); if (ship.health <= 0) { LK.showGameOver(); return; } } } } game.down = function (x, y, obj) { if (gameStarted) { createWave(x, y); } }; game.update = function () { if (!gameStarted) return; difficultyTimer++; monsterSpawnTimer++; // Increase difficulty over time if (difficultyTimer % 1800 === 0) { // Every 30 seconds monsterSpawnRate = Math.max(60, monsterSpawnRate - 10); } // Spawn monsters if (monsterSpawnTimer >= monsterSpawnRate) { spawnMonster(); monsterSpawnTimer = 0; } // Update and cleanup waves for (var w = waves.length - 1; w >= 0; w--) { var wave = waves[w]; if (wave.lifetime >= wave.maxLifetime) { wave.destroy(); waves.splice(w, 1); } } // Update monster targets to current ship position for (var m = 0; m < monsters.length; m++) { var monster = monsters[m]; monster.targetX = ship.x; monster.targetY = ship.y; } // Check collisions checkWaveMonsterCollisions(); checkMonsterShipCollisions(); // Remove off-screen monsters (safety cleanup) for (var m = monsters.length - 1; m >= 0; m--) { var monster = monsters[m]; if (monster.x < -100 || monster.x > 2148 || monster.y < -100 || monster.y > 2832) { monster.destroy(); monsters.splice(m, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -166,9 +166,9 @@
}
}
game.down = function (x, y, obj) {
if (gameStarted) {
- createWave(ship.x, ship.y);
+ createWave(x, y);
}
};
game.update = function () {
if (!gameStarted) return;