User prompt
Please fix the bug: 'Bunker is not defined' in or related to this line: 'var bunker = new Bunker();' Line Number: 165
User prompt
Errorl197 hatasını düzelt
User prompt
Please fix the bug: 'Sniper is not defined' in or related to this line: 'var sniper = new Sniper();' Line Number: 197
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Bunker is not defined' in or related to this line: 'var bunker = new Bunker();' Line Number: 165
User prompt
Yeni düşmanın görüntüsünü oluştur
User prompt
Bir noktadan sonra sayı 40'ı geçmesin düşman sayısı ne kadar artarsa artsın score ayrıca yeni canavarlar eklensin uzaktan menzilli saldırı canavarlar olsun ama menzili bizim sniper kadar büyük değil ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Müttefik karakterine yürüme animasyonu ekle yani yürürken kendi ekseninde çapraz şekilde bir sağa bir sola dönüyor
User prompt
güvenliğe müfettiğime yürüme animasyonu ekle
User prompt
düşmanların yürüme animasyonunu müfettike ekle
User prompt
müttefik askerin görselini yap
User prompt
herkes öldükten sonra maçın başlaması için olan geri sayım ben silah sıkmadan başlamıyor bu hatayı düzet. ayrıca düşman artması %25 olsun.
User prompt
Please fix the bug: 'Uncaught ReferenceError: bulletAngle is not defined' in or related to this line: 'var recoilX = recoilDirection * Math.cos(bulletAngle) * recoilDistance;' Line Number: 1146
User prompt
sniper rifle ve super sniper silahlarında bak var sola bakıp ateş ettiğimizde mermilerrde tuhaflık var arkadan geliyor veya mermi hiç ateşlenmiyor bunu çöz ayrıca sniper kuleleri hasar aldığında canı gösterilsin
User prompt
sniper riffle silahında sola kaydığında mermi arkadan ateşleniyor lütfen bunu düzelt
User prompt
düşmanlar sniper kulesine saldırsın
User prompt
bug lu silahı düzelt süper sniper
User prompt
müttefiğin canı altınde ne kadar kaldığı can barı ile gösterilsin süper sniper da bazen mermiler bir şekilde gitmiyor onuda düzelt ayrıca mütteefiğin hızı yavaş biraz hızlandır
User prompt
super sniper mermi sıkmıyor bu hatayı düzelt ayrı düşmanlar müttefiğe karşı takip ederek saldırsın
User prompt
bütün düşmanlar müttefiğe saldıra bilir
User prompt
yürüme animasyonu eklenmemiş onu düzel müttefikler için
User prompt
müttefiğin hasarı 1 olsun canı 100 olsun hızıı normal düşmanlardaki gibi olsun yürüme animasyonu düşmanlar ile bire bir olsn, sniper tower hasar 2 vuruyor canı 300 uzaktan menzilli olarak sıkıyor bunu öyle ayarla
User prompt
müttefik düşmanlara saldırmıyor onu düzelt
User prompt
düğme gözükmüyor sol alt köşeye yerleştir
User prompt
Please fix the bug: 'ReferenceError: ally is not defined' in or related to this line: 'if (ally && ally.active) {' Line Number: 1965
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScore: 0, currency: 0 }); /**** * Initialize Game ****/ var game = new LK.Game({ // No title, no description // Always backgroundColor is black backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create background // New enemy visual asset var background = game.attachAsset('background', { width: 2048, height: 2732, anchorX: 0, anchorY: 0, tint: 0xC2B280 // Apply dry land tint to the background }); // Game variables var bunkerHealth = 100; var maxBunkerHealth = 100; var bunkerY = 2732 - 100; // Position near bottom of screen var currency = 500; var difficulty = 1; var wave = 1; var enemySpawnRate = 3000; // ms between enemy spawns var lastEnemySpawn = 0; var gameActive = true; var waveInProgress = false; var enemyIncreasePerWave = 0.25; // 25% more enemies per wave var enemiesPerWave = 10; // Starting with 10 enemies var enemiesSpawned = 0; // Track enemies spawned in current wave var enemiesRequired = 10; // Initial enemies required for first wave // Magazine system for each weapon type var magazines = { basic: { max: 15, current: 15, reloading: false, reloadTime: 1200 }, sniper: { max: 10, current: 10, reloading: false, reloadTime: 1800 }, "super": { max: 5, current: 5, reloading: false, reloadTime: 2500 } }; // UI for ammo display var ammoTxt = new Text2('Ammo: 5/5', { size: 50, fill: 0xFFFF00 }); ammoTxt.anchor.set(1, 0); ammoTxt.x = 2048 - 80; ammoTxt.y = 60; LK.gui.top.addChild(ammoTxt); // Helper to update ammo UI function updateAmmoUI() { var weapon = sniper.currentWeapon; var mag = magazines[weapon]; if (mag.reloading) { ammoTxt.setText('Reloading...'); } else { ammoTxt.setText('Ammo: ' + mag.current + '/' + mag.max); } } // Upgrade costs and values var upgrades = { fireRate: { level: 1, cost: 10, value: 1000, // ms between shots increment: -100 // decrease time between shots }, bulletDamage: { level: 1, cost: 15, value: 1, increment: 1 // increase damage } }; // Arrays for tracking game objects var bullets = []; var enemies = []; var walls = []; var enemyProjectiles = []; // Track projectiles from ranged enemies // Ally instance (semi-transparent melee ally) var ally = null; // Create bunker var bunker = new Bunker(); bunker.x = 2048 / 2; bunker.y = bunkerY; game.addChild(bunker); // Create sniper var sniper = new Sniper(); sniper.x = 2048 / 2; sniper.y = bunkerY - 50; game.addChild(sniper); // Create weapon shop var weaponShop = new WeaponShop(); weaponShop.x = 350; // Moved more to the right for better visibility weaponShop.y = 1800; // Position higher on the screen for better visibility game.addChild(weaponShop); // Add to game instead of GUI for better positioning // Create building shop var buildingShop = new BuildingShop(); buildingShop.x = 400; // Moved further right to improve visibility and hit detection buildingShop.y = 600; // Repositioned lower on the screen for better accessibility game.addChild(buildingShop); // Create wave countdown timer var waveCountdown = new WaveCountdown(); waveCountdown.x = 2048 / 2; // Center horizontally waveCountdown.y = 2732 / 2; // Center vertically waveCountdown.visible = false; // Hide initially game.addChild(waveCountdown); // UI Elements // Score display var scoreTxt = new Text2('Score: 0', { size: 70, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); scoreTxt.y = 50; LK.gui.top.addChild(scoreTxt); // Ally purchase button (bottom left corner, visible) var allyBtnBg = LK.getAsset('bullet', { width: 260, height: 110, anchorX: 0.5, anchorY: 0.5, tint: 0x333333 }); allyBtnBg.alpha = 0.8; var allyBtn = new Text2("ALLY\n$100", { size: 55, fill: 0x00FFFF }); allyBtn.anchor.set(0.5, 0.5); var allyBtnContainer = new Container(); allyBtnContainer.addChild(allyBtnBg); allyBtnContainer.addChild(allyBtn); allyBtnContainer.x = 140; allyBtnContainer.y = 2732 - 140; allyBtnContainer.interactive = true; allyBtnContainer.visible = true; game.addChild(allyBtnContainer); // Ally button event allyBtnContainer.down = function (x, y, obj) { if (currency >= 100 && (!ally || !ally.active)) { currency -= 100; updateUI(); if (ally && !ally.active) { game.removeChild(ally); } ally = new Ally(); ally.x = sniper.x + 80; ally.y = sniper.y; game.addChild(ally); LK.effects.flashObject(ally, 0x00FFFF, 400); } else if (currency < 100) { LK.effects.flashObject(allyBtnContainer, 0xFF0000, 200); } }; // Wave display var waveTxt = new Text2('Wave: 1', { size: 50, fill: 0xFFFFFF }); waveTxt.anchor.set(1, 0); LK.gui.topLeft.addChild(waveTxt); waveTxt.x = 150; // Move away from the top left corner // Health display var healthTxt = new Text2('Bunker: 100%', { size: 50, fill: 0xFFFFFF }); healthTxt.anchor.set(0.5, 0); healthTxt.y = 130; LK.gui.top.addChild(healthTxt); // Currency display var currencyTxt = new Text2('$: 0', { size: 50, fill: 0x00FF00 }); currencyTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(currencyTxt); currencyTxt.x = 150; // Move away from top left corner currencyTxt.y = 60; // Position below wave display // Upgrade buttons removed as requested // Update UI elements function updateUI() { scoreTxt.setText('Score: ' + LK.getScore()); currencyTxt.setText('$: ' + currency); waveTxt.setText('Wave: ' + wave); updateUpgradeButtons(); } function updateBunkerHealth() { var healthPercentage = Math.max(0, Math.min(100, Math.round(bunkerHealth / maxBunkerHealth * 100))); healthTxt.setText('Bunker: ' + healthPercentage + '%'); bunker.showDamage(bunkerHealth / maxBunkerHealth); // Only make damage indicator visible and shake when actually taking damage // Don't show it during initialization // Only proceed with damage indication animations if bunker is actually taking damage if (bunkerHealth < maxBunkerHealth) { // Make damage indicator visible and shake when damage is taken bunker.damageIndicator.alpha = 1; // Shake effect tween(bunker.damageIndicator, { x: bunker.damageIndicator.originalX + (Math.random() * 10 - 5), y: bunker.damageIndicator.originalY + (Math.random() * 10 - 5) }, { duration: 50, repeat: 5, yoyo: true, onFinish: function onFinish() { // Hide damage indicator after shake completes (1 second) LK.setTimeout(function () { if (gameActive) { // Fade out damage indicator tween(bunker.damageIndicator, { alpha: 0 }, { duration: 300 }); } }, 1000); } }); } // Create a visual indicator effect when health is low if (bunkerHealth / maxBunkerHealth < 0.5) { // Add continuous damage indicator update for low health LK.setTimeout(function () { if (gameActive) bunker.showDamage(bunkerHealth / maxBunkerHealth); }, 100); } } function updateUpgradeButtons() { // Upgrade buttons removed as requested } // Game mechanics functions function spawnEnemy() { var now = Date.now(); if (!waveInProgress || now - lastEnemySpawn < enemySpawnRate) return; // Check if we've already spawned enough enemies for this wave if (enemiesSpawned >= enemiesRequired) return; lastEnemySpawn = now; // Calculate number of enemies to spawn based on score var currentScore = LK.getScore(); var enemiesToSpawnAtOnce = 1; // Default spawn one enemy at a time // Increase enemies spawned at once based on score thresholds if (currentScore >= 500) { enemiesToSpawnAtOnce = 5; // Spawn 5 enemies at once at high scores } else if (currentScore >= 300) { enemiesToSpawnAtOnce = 4; // Spawn 4 enemies at once } else if (currentScore >= 200) { enemiesToSpawnAtOnce = 3; // Spawn 3 enemies at once } else if (currentScore >= 100) { enemiesToSpawnAtOnce = 2; // Spawn 2 enemies at once } // Make sure we don't spawn more enemies than required for this wave enemiesToSpawnAtOnce = Math.min(enemiesToSpawnAtOnce, enemiesRequired - enemiesSpawned); // Spawn multiple enemies at once for (var i = 0; i < enemiesToSpawnAtOnce; i++) { // Determine enemy type based on score and wave progression var enemyType = 'regular'; var random = Math.random(); // More advanced enemies appear based on score thresholds if (currentScore >= 350 && random < 0.18) { enemyType = 'ranged'; } else if (currentScore >= 300 && random < 0.3) { enemyType = 'tank'; } else if (currentScore >= 200 && random < 0.18) { enemyType = 'ranged'; } else if (currentScore >= 150 && random < 0.25) { enemyType = 'tank'; } else if (currentScore >= 120 && random < 0.22) { enemyType = 'ranged'; } else if (currentScore >= 100 && random < 0.35) { enemyType = 'fast'; } else if (currentScore >= 50 && random < 0.25) { enemyType = 'fast'; } var enemy; if (enemyType === 'ranged') { enemy = new RangedEnemy(); } else { enemy = new Enemy(enemyType); } // Distribute enemies across the width of the screen if (enemiesToSpawnAtOnce > 1) { // Distribute evenly but with some randomness var segment = 2048 / enemiesToSpawnAtOnce; enemy.x = i * segment + Math.random() * (segment - 100) + 50; } else { enemy.x = Math.random() * (2048 - 100) + 50; // Random x position } enemy.y = -50; // Start above the screen enemies.push(enemy); game.addChild(enemy); // Increment enemies spawned counter enemiesSpawned++; } } function checkCollisions() { for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; if (!bullet.active) { game.removeChild(bullet); bullets.splice(i, 1); continue; } for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (!enemy.active) { game.removeChild(enemy); enemies.splice(j, 1); continue; } if (bullet.active && enemy.active && bullet.intersects(enemy)) { enemy.takeDamage(bullet.damage); bullet.hit(); break; } } } } function upgradeFireRate() { if (currency >= upgrades.fireRate.cost) { currency -= upgrades.fireRate.cost; upgrades.fireRate.level++; upgrades.fireRate.value += upgrades.fireRate.increment; // Ensure fire rate doesn't go below minimum upgrades.fireRate.value = Math.max(200, upgrades.fireRate.value); sniper.fireRate = upgrades.fireRate.value; // Increase cost for next upgrade upgrades.fireRate.cost = Math.floor(upgrades.fireRate.cost * 1.5); LK.getSound('upgrade').play(); updateUI(); } } function upgradeBulletDamage() { if (currency >= upgrades.bulletDamage.cost) { currency -= upgrades.bulletDamage.cost; upgrades.bulletDamage.level++; upgrades.bulletDamage.value += upgrades.bulletDamage.increment; sniper.bulletDamage = upgrades.bulletDamage.value; // Increase cost for next upgrade upgrades.bulletDamage.cost = Math.floor(upgrades.bulletDamage.cost * 1.5); LK.getSound('upgrade').play(); updateUI(); } } function increaseDifficulty() { // Check if all enemies for this wave are spawned and eliminated if (waveInProgress && enemiesSpawned >= enemiesRequired && enemies.length === 0) { // All enemies in current wave defeated, prepare for next wave wave++; // Calculate new enemies required for next wave (increase by 25%), but cap at 40 enemiesRequired = Math.ceil(enemiesPerWave * Math.pow(1 + 0.25, wave - 1)); if (enemiesRequired > 40) enemiesRequired = 40; // Reset enemies spawned counter enemiesSpawned = 0; // Decrease spawn rate with each wave (faster spawns) based on score and wave var currentScore = LK.getScore(); // More aggressive spawn rate reduction based on score var scoreBasedReduction = Math.min(2000, Math.floor(currentScore / 8) * 25); // Use an exponential reduction for higher scores to make spawns much faster if (currentScore > 300) { scoreBasedReduction += Math.min(1000, Math.pow(currentScore - 300, 1.2)); } // Set a lower minimum spawn rate for higher scores var minSpawnRate = currentScore > 400 ? 100 : currentScore > 200 ? 200 : 300; enemySpawnRate = Math.max(minSpawnRate, 3000 - wave * 200 - scoreBasedReduction); // Pause wave progression and show countdown waveInProgress = false; // Start countdown for next wave waveCountdown.startCountdown(function () { // When countdown completes, start the new wave startNewWave(); }); } } function startNewWave() { // Clear all existing enemies for (var i = enemies.length - 1; i >= 0; i--) { game.removeChild(enemies[i]); } enemies = []; // Reset enemies spawned counter enemiesSpawned = 0; // Update UI to show new wave and enemy count waveTxt.setText('Wave: ' + wave + ' (' + enemiesRequired + ' enemies)'); // Start spawning enemies again waveInProgress = true; // Flash screen to indicate new wave LK.effects.flashScreen(0x00FF00, 500); // Adjust difficulty based on score var currentScore = LK.getScore(); if (currentScore > 300) { difficulty = 5; } else if (currentScore > 200) { difficulty = 4; } else if (currentScore > 100) { difficulty = 3; } else if (currentScore > 50) { difficulty = 2; } else { difficulty = 1; } } function gameOver() { gameActive = false; // Save high score if (LK.getScore() > storage.highScore) { storage.highScore = LK.getScore(); } // Save currency for next game storage.currency = currency; // Show game over screen LK.showGameOver(); } // Event handlers game.move = function (x, y, obj) { if (gameActive) { // If placing a wall, move it with cursor if (game.isPlacing && game.placeableWall) { game.placeableWall.x = x; game.placeableWall.y = y; } else { // Otherwise update rifle aim to follow cursor var angle = sniper.updateAim(x, y); // Let the updateAim method handle the character orientation // We don't rotate the sniper character itself anymore // This prevents the character from being upside down when aiming } } }; game.down = function (x, y, obj) { if (!gameActive) return; // Check if weapon shop item was clicked if (weaponShop.checkItemClick(x, y)) { return; } // Check if building shop item was clicked if (buildingShop.checkItemClick(x, y)) { return; } // If placing a wall, place it at the clicked position if (game.isPlacing && game.placeableWall) { // Don't place near bunker or too close to top-left corner var distToBunker = Math.sqrt(Math.pow(x - bunker.x, 2) + Math.pow(y - bunker.y, 2)); var distToTopLeft = Math.sqrt(Math.pow(x - 100, 2) + Math.pow(y - 100, 2)); if (distToBunker < 150 || distToTopLeft < 100 || y > bunkerY - 50) { // Can't place here - flash red LK.effects.flashObject(game.placeableWall, 0xFF0000, 300); return; } // Create an actual wall at this position var wall = new Wall(game.placeableWall.buildingType, game.placeableWall.buildingHealth); wall.x = x; wall.y = y; game.addChild(wall); // Add to walls array if we don't have one if (!game.walls) { game.walls = []; } game.walls.push(wall); // Remove placeable wall game.removeChild(game.placeableWall); game.placeableWall = null; game.isPlacing = false; return; } // Fire at touch location (single shot for all weapons) var bullet = sniper.shoot(x, y); if (bullet) { bullets.push(bullet); game.addChild(bullet); } }; game.up = function (x, y, obj) { // No machine gun auto fire to stop }; // Update function called every frame game.update = function () { if (!gameActive) return; // Only spawn enemies if a wave is in progress if (waveInProgress) { // Spawn enemies spawnEnemy(); // Update enemies for (var i = 0; i < enemies.length; i++) { if (enemies[i].active) { enemies[i].update(); } } // Check for collisions checkCollisions(); } // Update bullets regardless of wave status for (var i = 0; i < bullets.length; i++) { if (bullets[i].active) { bullets[i].update(); } } // Update enemy projectiles for (var i = enemyProjectiles.length - 1; i >= 0; i--) { var proj = enemyProjectiles[i]; if (proj.active) { proj.update(); } else { if (typeof game !== "undefined" && typeof game.removeChild === "function") { game.removeChild(proj); } enemyProjectiles.splice(i, 1); } } // Update walls and check for wall-enemy collisions if (game.walls && game.walls.length > 0) { for (var i = game.walls.length - 1; i >= 0; i--) { var wall = game.walls[i]; // Update wall health bar wall.update(); // Check for collisions with enemies for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (enemy.active && wall.intersects(enemy)) { // Stop enemy and set it to attack the wall if (!enemy.isAttackingWall) { enemy.isAttackingWall = true; enemy.attackTarget = wall; enemy.attackAnimationTicks = 0; } // Check if wall was destroyed after the attack if (wall.health <= 0) { // Remove wall if destroyed game.removeChild(wall); game.walls.splice(i, 1); // Reset any enemies attacking this wall for (var k = 0; k < enemies.length; k++) { if (enemies[k].attackTarget === wall) { enemies[k].isAttackingWall = false; enemies[k].attackTarget = null; // Reset enemy position and rotation tween(enemies[k].graphics, { rotation: 0, y: 0 }, { duration: 200, easing: tween.easeOut }); } } break; } } } } } // Update muzzle flashes Object.keys(sniper.muzzleFlashes).forEach(function (key) { if (sniper.muzzleFlashes[key].active) { sniper.muzzleFlashes[key].update(); } }); // Update ally if present if (ally && ally.active) { ally.update(); } else if (ally && !ally.active) { // Remove dead ally from game game.removeChild(ally); ally = null; } // Update difficulty (handles wave transitions) increaseDifficulty(); // Continuously update damage indicator when health is low if (bunkerHealth / maxBunkerHealth < 0.4) { // Move damage indicator more frequently as health gets lower if (LK.ticks % Math.max(5, Math.floor(bunkerHealth / maxBunkerHealth * 20)) === 0) { bunker.showDamage(bunkerHealth / maxBunkerHealth); } } // Update UI if (LK.ticks % 30 === 0) { updateUI(); } }; // Make sure the weapon shop starts with the appropriate weapon equipped weaponShop.selectWeapon(0); // Start with basic rifle selected updateAmmoUI(); // Show initial ammo // Initialize UI updateUI(); // Ensure damage indicator is invisible at start bunker.damageIndicator.alpha = 0; updateBunkerHealth(); // Calculate initial enemies required for first wave enemiesRequired = enemiesPerWave; // Start the first wave with countdown waveInProgress = false; waveCountdown.startCountdown(function () { startNewWave(); }); // Place random bushes and trees around the game area function placeBushes() { // Number of decorative elements to place var bushCount = 25; var treeCount = 15; // Positions to avoid (bunker and sniper area) var avoidX = 2048 / 2; var avoidY = bunkerY; var avoidRadius = 200; // Also avoid the top-left corner where menu icon is located var topLeftX = 50; var topLeftY = 50; var topLeftRadius = 100; // Add bushes for (var i = 0; i < bushCount; i++) { var bush = new Bush(); // Keep generating positions until we find a suitable one var validPosition = false; var attempts = 0; while (!validPosition && attempts < 10) { // Generate random position bush.x = Math.random() * 2048; bush.y = Math.random() * 2732; // Check distance from bunker area var distToBunker = Math.sqrt(Math.pow(bush.x - avoidX, 2) + Math.pow(bush.y - avoidY, 2)); // Check distance from top-left corner var distToTopLeft = Math.sqrt(Math.pow(bush.x - topLeftX, 2) + Math.pow(bush.y - topLeftY, 2)); // Position is valid if it's away from both areas to avoid if (distToBunker > avoidRadius && distToTopLeft > topLeftRadius) { validPosition = true; } attempts++; } // Add bush behind other game elements (insert at the beginning of children array) game.addChildAt(bush, 0); } // Add trees for (var i = 0; i < treeCount; i++) { var tree = new Tree(); // Keep generating positions until we find a suitable one var validPosition = false; var attempts = 0; while (!validPosition && attempts < 10) { // Generate random position tree.x = Math.random() * 2048; tree.y = Math.random() * 2732; // Check distance from bunker area var distToBunker = Math.sqrt(Math.pow(tree.x - avoidX, 2) + Math.pow(tree.y - avoidY, 2)); // Check distance from top-left corner var distToTopLeft = Math.sqrt(Math.pow(tree.x - topLeftX, 2) + Math.pow(tree.y - topLeftY, 2)); // Position is valid if it's away from both areas to avoid if (distToBunker > avoidRadius && distToTopLeft > topLeftRadius) { validPosition = true; } attempts++; } // Add tree behind other game elements (insert at the beginning of children array) game.addChildAt(tree, 0); } } // Add bushes to the game placeBushes(); // Start background music LK.playMusic('gameBgMusic', { fade: { start: 0, end: 0.3, duration: 1000 } });
===================================================================
--- original.js
+++ change.js
@@ -7,67 +7,8 @@
currency: 0
});
/****
-* Classes
-****/
-// Bunker class definition
-var Bunker = Container.expand(function () {
- var self = Container.call(this);
- // Attach bunker image asset
- self.graphics = self.attachAsset('bunker', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- // Add a damage indicator overlay (red box, invisible by default)
- self.damageIndicator = self.attachAsset('damageIndicator', {
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0
- });
- self.damageIndicator.originalX = 0;
- self.damageIndicator.originalY = 0;
- // Show damage effect based on health ratio (0..1)
- self.showDamage = function (healthRatio) {
- // Fade in damage indicator if health is low
- if (healthRatio < 0.5) {
- self.damageIndicator.alpha = 0.5 + 0.5 * (1 - healthRatio);
- } else {
- self.damageIndicator.alpha = 0;
- }
- };
- return self;
-});
-// New enemy class using the new visual
-var NewEnemy = Container.expand(function () {
- var self = Container.call(this);
- // Attach the new enemy image asset
- self.graphics = self.attachAsset('newEnemy', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.active = true;
- self.health = 8;
- self.speed = 2.2;
- self.update = function () {
- if (!self.active) {
- return;
- }
- self.lastY = self.y;
- self.y += self.speed;
- // Add more behavior as needed
- };
- self.takeDamage = function (amount) {
- self.health -= amount;
- if (self.health <= 0) {
- self.active = false;
- self.visible = false;
- }
- };
- return self;
-});
-
-/****
* Initialize Game
****/
var game = new LK.Game({
// No title, no description
@@ -77,10 +18,10 @@
/****
* Game Code
****/
-// New enemy visual asset
// Create background
+// New enemy visual asset
var background = game.attachAsset('background', {
width: 2048,
height: 2732,
anchorX: 0,
@@ -308,11 +249,9 @@
// Create a visual indicator effect when health is low
if (bunkerHealth / maxBunkerHealth < 0.5) {
// Add continuous damage indicator update for low health
LK.setTimeout(function () {
- if (gameActive) {
- bunker.showDamage(bunkerHealth / maxBunkerHealth);
- }
+ if (gameActive) bunker.showDamage(bunkerHealth / maxBunkerHealth);
}, 100);
}
}
function updateUpgradeButtons() {
@@ -320,15 +259,11 @@
}
// Game mechanics functions
function spawnEnemy() {
var now = Date.now();
- if (!waveInProgress || now - lastEnemySpawn < enemySpawnRate) {
- return;
- }
+ if (!waveInProgress || now - lastEnemySpawn < enemySpawnRate) return;
// Check if we've already spawned enough enemies for this wave
- if (enemiesSpawned >= enemiesRequired) {
- return;
- }
+ if (enemiesSpawned >= enemiesRequired) return;
lastEnemySpawn = now;
// Calculate number of enemies to spawn based on score
var currentScore = LK.getScore();
var enemiesToSpawnAtOnce = 1; // Default spawn one enemy at a time
@@ -441,11 +376,9 @@
// All enemies in current wave defeated, prepare for next wave
wave++;
// Calculate new enemies required for next wave (increase by 25%), but cap at 40
enemiesRequired = Math.ceil(enemiesPerWave * Math.pow(1 + 0.25, wave - 1));
- if (enemiesRequired > 40) {
- enemiesRequired = 40;
- }
+ if (enemiesRequired > 40) enemiesRequired = 40;
// Reset enemies spawned counter
enemiesSpawned = 0;
// Decrease spawn rate with each wave (faster spawns) based on score and wave
var currentScore = LK.getScore();
@@ -522,11 +455,9 @@
}
}
};
game.down = function (x, y, obj) {
- if (!gameActive) {
- return;
- }
+ if (!gameActive) return;
// Check if weapon shop item was clicked
if (weaponShop.checkItemClick(x, y)) {
return;
}
@@ -571,11 +502,9 @@
// No machine gun auto fire to stop
};
// Update function called every frame
game.update = function () {
- if (!gameActive) {
- return;
- }
+ if (!gameActive) return;
// Only spawn enemies if a wave is in progress
if (waveInProgress) {
// Spawn enemies
spawnEnemy();
kaya. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
sopalı düşman adam . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
koşan ninja. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
tek gözlü dev. In-Game asset. 2d. High contrast. No shadows
barbed wire wall. In-Game asset. 2d. High contrast. No shadows
gözcü kulesi. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
yazıyı sil
Çöl haydut sniper. In-Game asset. 2d. High contrast. No shadows
önden zırhlı araç . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
zırhlı aracaın arkası. In-Game asset. 2d. High contrast. No shadows
sağa giden askeri yeşil renkte zırhlı araç. In-Game asset. 2d. High contrast. No shadows