User prompt
Oyun kasmaması için, Ram yenileme çalışması ekle.
User prompt
Yapay zeka hareketleri çok daha akıllıca olsun
User prompt
Oyuncu kulelerinin altında Player yazsın.
User prompt
Birim gönderimi, kule biriminin daima yarısı olsun.
User prompt
Düşman kulelerinin hareketleri aynı olmasın, hepsi farklı bir strateji sergilesin.
User prompt
Her düşmana rastgele bir isim ver. Sahip olduğu kulelerin alt kısmında düşman isimleri yazsın.
User prompt
Birimler sıra halinde değil de; Dağınık şekilde ilerlesinler.
User prompt
Oyun ekran boyutunun tamamını %50 oranında Büyüt.
User prompt
Birden fazla düşman olsun. Düşmanlar da birbirleri ile savaşabilsin.
User prompt
Oyun ekran boyutunun tamamını %50 oranında küçült.
User prompt
Birimler savaşırken küçük görsel oluştur. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
**Seçim vurguları**: Seçili kulelerin etrafında dönen renk halkaları - **Hedef göstergeleri**: Sürüklerken hedef kulenin renkli yanıp sönmesi ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Powerup geliştirmelerine de, düşmana asker gönderiyor gibi, asker gönderelim. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
**Güçlendirici objeler**: Haritada rastgele beliren, geçici güç veren objeler. Asker göndererek bunları aktif etme. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
**Özel kule tipleri**: Savunma kulesi (mor), hızlı saldırı kulesi (turuncu), üretim kulesi (altın)
User prompt
**Parçacık sistemleri**: Savaş sırasında patlama efektleri, kulelerde birim üretimi sırasında ışık parçacıkları ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
**Renk geçişleri**: Kulelerin sahiplik değişimi sırasında yumuşak renk geçişleri ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Kulelerde, ne kadar fazla birim varsa; birim üretim hızı ona nazaran bir tık fazla olsun.
User prompt
Sağ alt kenara Reset butonu ekle. Basınca herşey sıfırlansın.
User prompt
Seviye sayısını 3 yerine 10 yap. ona göre zorluk sistemi belirle.
User prompt
Başlangıçta, her zaman düşman kulesinden 10 birim fazla olacak şekilde başlasın.
User prompt
Maksimum asker sayısı 50 yerine 100 olsun.
User prompt
Game over olunca herşey sıfırdan başlasın.
User prompt
Oyun başlayınca 5 saniye rakip beklesin. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Düşman birlikleri ile karşılaşan askerler savaşsın ve birbirini yok etsin.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Particle = Container.expand(function () { var self = Container.call(this); self.vx = 0; self.vy = 0; self.life = 60; self.maxLife = 60; var particleGraphics = self.attachAsset('particle', { anchorX: 0.5, anchorY: 0.5 }); self.setVelocity = function (vx, vy) { self.vx = vx; self.vy = vy; }; self.setLife = function (life) { self.life = life; self.maxLife = life; }; self.setColor = function (color) { particleGraphics.tint = color; }; self.update = function () { self.x += self.vx; self.y += self.vy; self.life--; // Fade out over time particleGraphics.alpha = self.life / self.maxLife; // Gravity effect self.vy += 0.2; // Remove when life expires if (self.life <= 0) { self.destroy(); var index = particles.indexOf(self); if (index !== -1) { particles.splice(index, 1); } } }; return self; }); var PathLine = Container.expand(function () { var self = Container.call(this); self.points = []; self.graphics = []; self.setPath = function (points) { // Clear old graphics for (var i = 0; i < self.graphics.length; i++) { self.graphics[i].destroy(); } self.graphics = []; self.points = points; // Draw new path for (var i = 0; i < points.length - 1; i++) { var dist = Math.sqrt(Math.pow(points[i + 1].x - points[i].x, 2) + Math.pow(points[i + 1].y - points[i].y, 2)); var segments = Math.floor(dist / 20); for (var j = 0; j < segments; j++) { var t = j / segments; var dot = self.attachAsset('path', { anchorX: 0.5, anchorY: 0.5 }); dot.x = points[i].x + (points[i + 1].x - points[i].x) * t; dot.y = points[i].y + (points[i + 1].y - points[i].y) * t; dot.alpha = 0.5; self.graphics.push(dot); } } }; self.clear = function () { for (var i = 0; i < self.graphics.length; i++) { self.graphics[i].destroy(); } self.graphics = []; self.points = []; }; return self; }); var Tower = Container.expand(function () { var self = Container.call(this); self.owner = 0; // 0 = neutral, 1 = player, 2 = enemy self.unitCount = 0; self.maxUnits = 100; self.spawnRate = 30; // ticks between spawns self.lastSpawn = 0; var towerGraphics = self.attachAsset('tower', { anchorX: 0.5, anchorY: 0.5 }); self.countText = new Text2('0', { size: 60, fill: 0xFFFFFF }); self.countText.anchor.set(0.5, 0.5); self.addChild(self.countText); self.setOwner = function (newOwner) { var oldOwner = self.owner; self.owner = newOwner; var targetColor; if (newOwner === 0) { targetColor = 0x888888; // neutral gray } else if (newOwner === 1) { targetColor = 0x4a90e2; // player blue } else { targetColor = 0xe74c3c; // enemy red } // Only animate if ownership actually changed if (oldOwner !== newOwner) { // Smooth color transition over 500ms tween(towerGraphics, { tint: targetColor }, { duration: 500, easing: tween.easeInOut }); } else { // Immediate color change if no ownership change towerGraphics.tint = targetColor; } }; self.addUnits = function (count) { self.unitCount = Math.min(self.unitCount + count, self.maxUnits); self.countText.setText(Math.floor(self.unitCount)); }; self.removeUnits = function (count) { self.unitCount = Math.max(0, self.unitCount - count); self.countText.setText(Math.floor(self.unitCount)); return count; }; self.update = function () { if (self.owner > 0) { // Calculate dynamic spawn rate based on unit count // More units = faster production (lower spawn rate number) // Base rate is 30, reduced by unit count factor var dynamicSpawnRate = Math.max(10, self.spawnRate - Math.floor(self.unitCount / 10)); if (LK.ticks - self.lastSpawn > dynamicSpawnRate) { self.addUnits(1); self.lastSpawn = LK.ticks; // Create production particles var particleColor = self.owner === 1 ? 0x4a90e2 : 0xe74c3c; createProductionParticles(self.x, self.y, particleColor); } } }; return self; }); var Unit = Container.expand(function () { var self = Container.call(this); self.owner = 1; self.speed = 3; self.targetTower = null; self.pathIndex = 0; self.path = []; var unitGraphics = self.attachAsset('unit', { anchorX: 0.5, anchorY: 0.5 }); self.setOwner = function (owner) { self.owner = owner; if (owner === 1) { unitGraphics.tint = 0x4a90e2; // player blue } else { unitGraphics.tint = 0xe74c3c; // enemy red } }; self.setPath = function (path, target) { self.path = path; self.targetTower = target; self.pathIndex = 0; if (path.length > 0) { self.x = path[0].x; self.y = path[0].y; } }; self.lastWasIntersecting = false; self.update = function () { if (!self.targetTower || self.pathIndex >= self.path.length) { return; } // Check for combat with enemy units var currentIntersecting = false; for (var i = 0; i < units.length; i++) { var otherUnit = units[i]; if (otherUnit !== self && otherUnit.owner !== self.owner) { // Check if units are close enough to fight (within 30 pixels) var combatDx = self.x - otherUnit.x; var combatDy = self.y - otherUnit.y; var combatDist = Math.sqrt(combatDx * combatDx + combatDy * combatDy); if (combatDist < 30) { currentIntersecting = true; // Combat occurs - both units destroy each other if (!self.lastWasIntersecting) { // Create explosion particles at combat location createExplosionParticles(self.x, self.y, 0xff4444, 8); createExplosionParticles(otherUnit.x, otherUnit.y, 0xff4444, 8); // Flash both units red before destroying LK.effects.flashObject(self, 0xff0000, 200); LK.effects.flashObject(otherUnit, 0xff0000, 200); LK.getSound('combat').play(); // Destroy both units after flash LK.setTimeout(function () { if (self && self.parent) { self.destroy(); var selfIndex = units.indexOf(self); if (selfIndex !== -1) { units.splice(selfIndex, 1); } } if (otherUnit && otherUnit.parent) { otherUnit.destroy(); var otherIndex = units.indexOf(otherUnit); if (otherIndex !== -1) { units.splice(otherIndex, 1); } } }, 200); return; } } } } self.lastWasIntersecting = currentIntersecting; var target = self.path[self.pathIndex]; var dx = target.x - self.x; var dy = target.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < self.speed) { self.pathIndex++; if (self.pathIndex >= self.path.length && self.targetTower) { // Reached target tower if (self.targetTower.owner === self.owner) { self.targetTower.addUnits(1); } else { self.targetTower.unitCount--; if (self.targetTower.unitCount < 0) { self.targetTower.unitCount = 1; self.targetTower.setOwner(self.owner); LK.getSound('capture').play(); } self.targetTower.countText.setText(Math.floor(Math.abs(self.targetTower.unitCount))); } self.destroy(); units.splice(units.indexOf(self), 1); } } else { self.x += dx / dist * self.speed; self.y += dy / dist * self.speed; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ var towers = []; var units = []; var particles = []; var currentPath = null; var selectedTower = null; var isDragging = false; var currentLevel = storage.currentLevel || 0; var aiStartTime = null; // Track when AI should start (null = not started yet) // Level configurations - 10 levels with progressive difficulty var levels = [{ // Level 1 - Tutorial towers: [{ x: 300, y: 1366, owner: 1, units: 30 }, { x: 1024, y: 800, owner: 0, units: 10 }, { x: 1748, y: 1366, owner: 2, units: 20 }] }, { // Level 2 - Basic Strategy towers: [{ x: 300, y: 400, owner: 1, units: 35 }, { x: 1024, y: 1366, owner: 0, units: 15 }, { x: 1748, y: 400, owner: 2, units: 25 }, { x: 1748, y: 2332, owner: 2, units: 25 }] }, { // Level 3 - Multi-Front towers: [{ x: 300, y: 1366, owner: 1, units: 45 }, { x: 700, y: 800, owner: 0, units: 15 }, { x: 1348, y: 800, owner: 0, units: 15 }, { x: 700, y: 1932, owner: 0, units: 15 }, { x: 1348, y: 1932, owner: 0, units: 15 }, { x: 1748, y: 1366, owner: 2, units: 35 }] }, { // Level 4 - Defensive Challenge towers: [{ x: 300, y: 1366, owner: 1, units: 50 }, { x: 600, y: 600, owner: 0, units: 20 }, { x: 1024, y: 400, owner: 2, units: 40 }, { x: 1448, y: 600, owner: 0, units: 20 }, { x: 1748, y: 1366, owner: 2, units: 40 }, { x: 1024, y: 2100, owner: 2, units: 40 }] }, { // Level 5 - Resource Management towers: [{ x: 200, y: 800, owner: 1, units: 55 }, { x: 200, y: 1932, owner: 1, units: 55 }, { x: 700, y: 1366, owner: 0, units: 25 }, { x: 1348, y: 1366, owner: 0, units: 25 }, { x: 1748, y: 600, owner: 2, units: 45 }, { x: 1748, y: 1366, owner: 2, units: 45 }, { x: 1748, y: 2132, owner: 2, units: 45 }] }, { // Level 6 - Territory Control towers: [{ x: 300, y: 400, owner: 1, units: 60 }, { x: 300, y: 2332, owner: 1, units: 60 }, { x: 600, y: 800, owner: 0, units: 30 }, { x: 1024, y: 1366, owner: 0, units: 30 }, { x: 1448, y: 1932, owner: 0, units: 30 }, { x: 1748, y: 800, owner: 2, units: 50 }, { x: 1748, y: 1500, owner: 2, units: 50 }, { x: 1748, y: 2200, owner: 2, units: 50 }] }, { // Level 7 - Advanced Tactics towers: [{ x: 200, y: 1366, owner: 1, units: 65 }, { x: 500, y: 600, owner: 0, units: 35 }, { x: 500, y: 1366, owner: 0, units: 35 }, { x: 500, y: 2132, owner: 0, units: 35 }, { x: 1024, y: 400, owner: 0, units: 35 }, { x: 1024, y: 2332, owner: 0, units: 35 }, { x: 1548, y: 600, owner: 0, units: 35 }, { x: 1548, y: 1366, owner: 0, units: 35 }, { x: 1548, y: 2132, owner: 0, units: 35 }, { x: 1848, y: 1366, owner: 2, units: 55 }] }, { // Level 8 - Siege Warfare towers: [{ x: 300, y: 600, owner: 1, units: 70 }, { x: 300, y: 1366, owner: 1, units: 70 }, { x: 300, y: 2132, owner: 1, units: 70 }, { x: 800, y: 800, owner: 0, units: 40 }, { x: 800, y: 1932, owner: 0, units: 40 }, { x: 1248, y: 800, owner: 0, units: 40 }, { x: 1248, y: 1932, owner: 0, units: 40 }, { x: 1650, y: 400, owner: 2, units: 60 }, { x: 1650, y: 1366, owner: 2, units: 60 }, { x: 1650, y: 2332, owner: 2, units: 60 }] }, { // Level 9 - Final Challenge towers: [{ x: 200, y: 800, owner: 1, units: 75 }, { x: 200, y: 1932, owner: 1, units: 75 }, { x: 600, y: 400, owner: 0, units: 45 }, { x: 600, y: 1366, owner: 0, units: 45 }, { x: 600, y: 2332, owner: 0, units: 45 }, { x: 1024, y: 600, owner: 0, units: 45 }, { x: 1024, y: 2132, owner: 0, units: 45 }, { x: 1448, y: 400, owner: 0, units: 45 }, { x: 1448, y: 1366, owner: 0, units: 45 }, { x: 1448, y: 2333, owner: 0, units: 45 }, { x: 1748, y: 600, owner: 2, units: 65 }, { x: 1748, y: 1366, owner: 2, units: 65 }, { x: 1748, y: 2132, owner: 2, units: 65 }] }, { // Level 10 - Master's Trial towers: [{ x: 150, y: 1366, owner: 1, units: 80 }, { x: 400, y: 600, owner: 0, units: 50 }, { x: 400, y: 1100, owner: 0, units: 50 }, { x: 400, y: 1632, owner: 0, units: 50 }, { x: 400, y: 2132, owner: 0, units: 50 }, { x: 800, y: 400, owner: 0, units: 50 }, { x: 800, y: 800, owner: 0, units: 50 }, { x: 800, y: 1932, owner: 0, units: 50 }, { x: 800, y: 2333, owner: 0, units: 50 }, { x: 1248, y: 400, owner: 0, units: 50 }, { x: 1248, y: 800, owner: 0, units: 50 }, { x: 1248, y: 1932, owner: 0, units: 50 }, { x: 1248, y: 2333, owner: 0, units: 50 }, { x: 1648, y: 600, owner: 0, units: 50 }, { x: 1648, y: 1100, owner: 0, units: 50 }, { x: 1648, y: 1632, owner: 0, units: 50 }, { x: 1648, y: 2132, owner: 0, units: 50 }, { x: 1898, y: 1366, owner: 2, units: 70 }] }]; // UI Elements var levelText = new Text2('Level ' + (currentLevel + 1), { size: 80, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0); LK.gui.top.addChild(levelText); function loadLevel(levelIndex) { // Clear existing game objects for (var i = 0; i < towers.length; i++) { towers[i].destroy(); } for (var i = 0; i < units.length; i++) { units[i].destroy(); } for (var i = 0; i < particles.length; i++) { particles[i].destroy(); } towers = []; units = []; particles = []; if (currentPath) { currentPath.destroy(); currentPath = null; } // Reset game state variables selectedTower = null; isDragging = false; // Load new level var levelData = levels[levelIndex % levels.length]; for (var i = 0; i < levelData.towers.length; i++) { var towerData = levelData.towers[i]; var tower = new Tower(); tower.x = towerData.x; tower.y = towerData.y; tower.setOwner(towerData.owner); tower.addUnits(towerData.units); towers.push(tower); game.addChild(tower); } levelText.setText('Level ' + (levelIndex + 1)); // Set AI to start after 5 seconds (5000ms) aiStartTime = LK.ticks + 5 * 60; // 5 seconds at 60 FPS } function createExplosionParticles(x, y, color, count) { for (var i = 0; i < count; i++) { var particle = new Particle(); particle.x = x; particle.y = y; particle.setColor(color); particle.setLife(30 + Math.random() * 30); // Random explosion velocity var angle = Math.random() * Math.PI * 2; var speed = 2 + Math.random() * 4; particle.setVelocity(Math.cos(angle) * speed, Math.sin(angle) * speed - 2); particles.push(particle); game.addChild(particle); } } function createProductionParticles(x, y, color) { for (var i = 0; i < 3; i++) { var particle = new Particle(); particle.x = x + (Math.random() - 0.5) * 60; particle.y = y + (Math.random() - 0.5) * 60; particle.setColor(color); particle.setLife(20 + Math.random() * 20); // Upward floating motion particle.setVelocity((Math.random() - 0.5) * 2, -1 - Math.random() * 2); particles.push(particle); game.addChild(particle); } } function createPath(start, end) { var points = []; var steps = 20; for (var i = 0; i <= steps; i++) { points.push({ x: start.x + (end.x - start.x) * (i / steps), y: start.y + (end.y - start.y) * (i / steps) }); } return points; } function sendUnits(fromTower, toTower, count) { var path = createPath(fromTower, toTower); var unitsToSend = Math.min(count, fromTower.unitCount); for (var i = 0; i < unitsToSend; i++) { var unit = new Unit(); unit.setOwner(fromTower.owner); unit.setPath(path, toTower); units.push(unit); game.addChild(unit); // Stagger unit spawning tween(unit, { x: path[0].x, y: path[0].y }, { duration: i * 50, onFinish: function onFinish() { LK.getSound('deploy').play(); } }); } fromTower.removeUnits(unitsToSend); } function checkWinCondition() { var playerTowers = 0; var enemyTowers = 0; for (var i = 0; i < towers.length; i++) { if (towers[i].owner === 1) playerTowers++; if (towers[i].owner === 2) enemyTowers++; } if (enemyTowers === 0) { // Win condition currentLevel++; storage.currentLevel = currentLevel; LK.showYouWin(); } else if (playerTowers === 0) { // Lose condition - reset everything to start from beginning currentLevel = 0; storage.currentLevel = 0; LK.showGameOver(); } } // Simple AI function runAI() { // Don't run AI until 5 seconds have passed if (aiStartTime && LK.ticks < aiStartTime) { return; } for (var i = 0; i < towers.length; i++) { var tower = towers[i]; if (tower.owner === 2 && tower.unitCount > 15) { // Find nearest non-enemy tower var nearestTower = null; var nearestDist = Infinity; for (var j = 0; j < towers.length; j++) { if (towers[j].owner !== 2) { var dx = towers[j].x - tower.x; var dy = towers[j].y - tower.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < nearestDist) { nearestDist = dist; nearestTower = towers[j]; } } } if (nearestTower) { sendUnits(tower, nearestTower, Math.floor(tower.unitCount * 0.8)); } } } } game.down = function (x, y, obj) { // Find if we clicked on a player tower for (var i = 0; i < towers.length; i++) { var tower = towers[i]; if (tower.owner === 1 && Math.abs(tower.x - x) < 75 && Math.abs(tower.y - y) < 75) { selectedTower = tower; isDragging = true; if (!currentPath) { currentPath = new PathLine(); game.addChild(currentPath); } currentPath.setPath([{ x: tower.x, y: tower.y }]); break; } } }; game.move = function (x, y, obj) { if (isDragging && selectedTower && currentPath) { currentPath.setPath([{ x: selectedTower.x, y: selectedTower.y }, { x: x, y: y }]); } }; game.up = function (x, y, obj) { if (isDragging && selectedTower) { // Find target tower var targetTower = null; for (var i = 0; i < towers.length; i++) { var tower = towers[i]; if (tower !== selectedTower && Math.abs(tower.x - x) < 75 && Math.abs(tower.y - y) < 75) { targetTower = tower; break; } } if (targetTower && selectedTower.unitCount > 0) { sendUnits(selectedTower, targetTower, Math.floor(selectedTower.unitCount * 0.8)); } if (currentPath) { currentPath.clear(); } } isDragging = false; selectedTower = null; }; game.update = function () { // Update all units for (var i = units.length - 1; i >= 0; i--) { if (!units[i] || !units[i].parent) { units.splice(i, 1); } } // Update all particles for (var i = particles.length - 1; i >= 0; i--) { if (!particles[i] || !particles[i].parent) { particles.splice(i, 1); } } // Run AI every 2 seconds if (LK.ticks % 120 === 0) { runAI(); } // Check win/lose conditions if (LK.ticks % 60 === 0) { checkWinCondition(); } }; // Create Reset button var resetButton = new Text2('Reset', { size: 60, fill: 0xFFFFFF }); resetButton.anchor.set(1, 1); // Anchor to bottom right LK.gui.bottomRight.addChild(resetButton); // Reset button functionality resetButton.down = function (x, y, obj) { // Reset all game state currentLevel = 0; storage.currentLevel = 0; // Clear existing game objects for (var i = 0; i < towers.length; i++) { towers[i].destroy(); } for (var i = 0; i < units.length; i++) { units[i].destroy(); } for (var i = 0; i < particles.length; i++) { particles[i].destroy(); } towers = []; units = []; particles = []; if (currentPath) { currentPath.destroy(); currentPath = null; } // Reset game state variables selectedTower = null; isDragging = false; aiStartTime = null; // Load first level loadLevel(currentLevel); }; // Initialize first level loadLevel(currentLevel); // Play background music LK.playMusic('battle'); ;
===================================================================
--- original.js
+++ change.js
@@ -6,8 +6,48 @@
/****
* Classes
****/
+var Particle = Container.expand(function () {
+ var self = Container.call(this);
+ self.vx = 0;
+ self.vy = 0;
+ self.life = 60;
+ self.maxLife = 60;
+ var particleGraphics = self.attachAsset('particle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.setVelocity = function (vx, vy) {
+ self.vx = vx;
+ self.vy = vy;
+ };
+ self.setLife = function (life) {
+ self.life = life;
+ self.maxLife = life;
+ };
+ self.setColor = function (color) {
+ particleGraphics.tint = color;
+ };
+ self.update = function () {
+ self.x += self.vx;
+ self.y += self.vy;
+ self.life--;
+ // Fade out over time
+ particleGraphics.alpha = self.life / self.maxLife;
+ // Gravity effect
+ self.vy += 0.2;
+ // Remove when life expires
+ if (self.life <= 0) {
+ self.destroy();
+ var index = particles.indexOf(self);
+ if (index !== -1) {
+ particles.splice(index, 1);
+ }
+ }
+ };
+ return self;
+});
var PathLine = Container.expand(function () {
var self = Container.call(this);
self.points = [];
self.graphics = [];
@@ -103,8 +143,11 @@
var dynamicSpawnRate = Math.max(10, self.spawnRate - Math.floor(self.unitCount / 10));
if (LK.ticks - self.lastSpawn > dynamicSpawnRate) {
self.addUnits(1);
self.lastSpawn = LK.ticks;
+ // Create production particles
+ var particleColor = self.owner === 1 ? 0x4a90e2 : 0xe74c3c;
+ createProductionParticles(self.x, self.y, particleColor);
}
}
};
return self;
@@ -154,8 +197,11 @@
if (combatDist < 30) {
currentIntersecting = true;
// Combat occurs - both units destroy each other
if (!self.lastWasIntersecting) {
+ // Create explosion particles at combat location
+ createExplosionParticles(self.x, self.y, 0xff4444, 8);
+ createExplosionParticles(otherUnit.x, otherUnit.y, 0xff4444, 8);
// Flash both units red before destroying
LK.effects.flashObject(self, 0xff0000, 200);
LK.effects.flashObject(otherUnit, 0xff0000, 200);
LK.getSound('combat').play();
@@ -223,8 +269,9 @@
* Game Code
****/
var towers = [];
var units = [];
+var particles = [];
var currentPath = null;
var selectedTower = null;
var isDragging = false;
var currentLevel = storage.currentLevel || 0;
@@ -700,10 +747,14 @@
}
for (var i = 0; i < units.length; i++) {
units[i].destroy();
}
+ for (var i = 0; i < particles.length; i++) {
+ particles[i].destroy();
+ }
towers = [];
units = [];
+ particles = [];
if (currentPath) {
currentPath.destroy();
currentPath = null;
}
@@ -725,8 +776,36 @@
levelText.setText('Level ' + (levelIndex + 1));
// Set AI to start after 5 seconds (5000ms)
aiStartTime = LK.ticks + 5 * 60; // 5 seconds at 60 FPS
}
+function createExplosionParticles(x, y, color, count) {
+ for (var i = 0; i < count; i++) {
+ var particle = new Particle();
+ particle.x = x;
+ particle.y = y;
+ particle.setColor(color);
+ particle.setLife(30 + Math.random() * 30);
+ // Random explosion velocity
+ var angle = Math.random() * Math.PI * 2;
+ var speed = 2 + Math.random() * 4;
+ particle.setVelocity(Math.cos(angle) * speed, Math.sin(angle) * speed - 2);
+ particles.push(particle);
+ game.addChild(particle);
+ }
+}
+function createProductionParticles(x, y, color) {
+ for (var i = 0; i < 3; i++) {
+ var particle = new Particle();
+ particle.x = x + (Math.random() - 0.5) * 60;
+ particle.y = y + (Math.random() - 0.5) * 60;
+ particle.setColor(color);
+ particle.setLife(20 + Math.random() * 20);
+ // Upward floating motion
+ particle.setVelocity((Math.random() - 0.5) * 2, -1 - Math.random() * 2);
+ particles.push(particle);
+ game.addChild(particle);
+ }
+}
function createPath(start, end) {
var points = [];
var steps = 20;
for (var i = 0; i <= steps; i++) {
@@ -864,8 +943,14 @@
if (!units[i] || !units[i].parent) {
units.splice(i, 1);
}
}
+ // Update all particles
+ for (var i = particles.length - 1; i >= 0; i--) {
+ if (!particles[i] || !particles[i].parent) {
+ particles.splice(i, 1);
+ }
+ }
// Run AI every 2 seconds
if (LK.ticks % 120 === 0) {
runAI();
}
@@ -892,10 +977,14 @@
}
for (var i = 0; i < units.length; i++) {
units[i].destroy();
}
+ for (var i = 0; i < particles.length; i++) {
+ particles[i].destroy();
+ }
towers = [];
units = [];
+ particles = [];
if (currentPath) {
currentPath.destroy();
currentPath = null;
}
Saldırı kulesi, Gerçekçi, kuş bakışı görünüm, yazısız.. In-Game asset. High contrast. No shadows, 3d olsun.
Saldırı kulesi, Gerçekçi, kuş bakışı görünüm, yazısız.. In-Game asset. High contrast. No shadows, 3d olsun.
Gece çölü arkaplan resmi, Gerçekçi, kuş bakışı görünüm, yazısız. susuz. In-Game asset. High contrast. No shadows, 3d olsun..
Kılıç ve kalkanlı çağı saldırı askeri, Gerçekçi, kuş bakışı görünüm, yazısız.. In-Game asset. High contrast. No shadows, renkli 3d olsun.