User prompt
önceden eklediğimiz +10 score yazısını kaldır sadece cheats olsun ve arkaplanı dursun
User prompt
score yazısının altına CHEATS diye bir tıklanabilir menü ekle tıklandığında oyun dursun ve içerisindeki guide +10 score, god mode, game speed (2x, 3x) seçilebilir seçenekler ekle
User prompt
Paramız yetmese bile silaha tıkladığımızda buy ekranı açılsın. Eğer paramız yetmiyorsa "Para yetersiz" uyarısı çıksın ve sahip olmadığımız silahların üzeri kırmızı gözüksün. Silahların sağ tarafta durduğu yerin arkaplanına da gui yap
User prompt
Silahları aldığımızda puanımız düşsün pompalının fiyatı 20 skor olsun. smg puanı 100 olsun sniper da 100 olsun satın tıkladığımızda "BUY" yazılı bir seçme yeri gelsin. arkaplanı da olsun gui olur. düşmanların canı üzerlerinde bar olarak yazsın
User prompt
Sniper silahının menzili şuankinden 3 kat fazla olsun. Smg atış hızı çok fazla %80 yavaşlasın
User prompt
Pompalı ile sıktığımızda 3 mermi fırlatsın, smg ile sıktığımızda basılı tutunca tarasın, awp ile sıktığımızda adamı öldürsün mermi delsin arkaya geçsin
User prompt
oynadığımız alanın arkaplanını değiştirmek için de bir asset ekle ve sağ orta tarafa 3 farklı silah ekle : pompalı, smg, sniper bunların damage ve atış hızını kendine göre ayarla
User prompt
50. sıradaki boss 75. sıradaki boss ve 100. sıradaki bossun assetleri farklı olsun ve canları şöyle olsun: 50. sıradaki 20 , 75. sıradaki için 30 , 100. sıradaki için 50 can
User prompt
boss öldüğü esnada ölüm sesi de ekle ve +10 score yazan yerin arkasına hafif opaklığı kısık siyah arkaplan yap ki buton olduğu belli olsun. Ve arkaplan için de asset ayarı ekle
User prompt
Score yazısının tam altına tıklanabilir bir buton koy ve bu butona bastığımızda +10 skor eklensin ve sağ üst kısıma High Score yeri koy ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
her 25 skorda bir boss gelsin ve bu 10 vuruşta öldürülebilsin onun için de ayrı bir texture olsun ve bu boss geldiğinde müzik eklensin
User prompt
Her 10 skorda rakipler %10 daha hızlı olsun
User prompt
Mouse nereye bakarsa karakter de oraya baksın ve her yön için farklı asset de ekle
Code edit (1 edits merged)
Please save this source code
User prompt
Strike Zone - Top-Down Tactical Shooter
Initial prompt
Create a simple 2D top-down shooter game inspired by Counter-Strike, using Python and Pygame. 🔹 Features: The player is a rectangle or sprite that can move in 4 directions using WASD Aim and shoot using the mouse (left click fires bullets) Bullets move in the direction of the mouse and disappear on impact Enemies spawn randomly and move toward the player Basic health system: player dies if touched by enemy Score system: +1 point per enemy killed 🔹 Controls: Move: W = Up, A = Left, S = Down, D = Right Aim: Move the mouse cursor Shoot: Left Mouse Click 🔹 Extra (Optional): Add reload with R key, limited bullets per magazine Add a simple main menu and restart screen Please provide clean, well-commented code.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Boss = Container.expand(function (bossType) { var self = Container.call(this); // Determine boss asset and health based on type var assetId = 'boss'; var health = 10; if (bossType === 50) { assetId = 'boss50'; health = 20; } else if (bossType === 75) { assetId = 'boss75'; health = 30; } else if (bossType === 100) { assetId = 'boss100'; health = 50; } var bossGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0.8; self.health = health; self.maxHealth = health; self.bossType = bossType || 25; self.isBoss = true; self.lastPlayerX = 0; self.lastPlayerY = 0; // Create health bar var healthBarWidth = bossGraphics.width * 0.8; var healthBarBackground = LK.getAsset('buttonBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: healthBarWidth / 260, scaleY: 0.3 }); healthBarBackground.y = -bossGraphics.height / 2 - 30; self.addChild(healthBarBackground); var healthBar = LK.getAsset('buyButton', { anchorX: 0.5, anchorY: 0.5, scaleX: healthBarWidth / 200, scaleY: 0.4 }); healthBar.y = -bossGraphics.height / 2 - 30; healthBar.tint = 0x00ff00; self.addChild(healthBar); self.healthBar = healthBar; self.healthBarBackground = healthBarBackground; self.update = function () { if (player) { var dx = player.x - self.x; var dy = player.y - 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; } self.lastPlayerX = player.x; self.lastPlayerY = player.y; } }; self.takeDamage = function (damage) { damage = damage || 1; self.health -= damage; LK.effects.flashObject(self, 0xFF4444, 200); // Update health bar var healthPercent = self.health / self.maxHealth; self.healthBar.scaleX = self.healthBarBackground.width * healthPercent / 200; if (healthPercent > 0.5) { self.healthBar.tint = 0x00ff00; } else if (healthPercent > 0.25) { self.healthBar.tint = 0xffff00; } else { self.healthBar.tint = 0xff0000; } if (self.health <= 0) { LK.effects.flashObject(self, 0xFFFFFF, 500); return true; } return false; }; return self; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.velocityX = 0; self.velocityY = 0; self.lifeTime = 120; self.age = 0; self.setDirection = function (targetX, targetY) { var dx = targetX - self.x; var dy = targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { self.velocityX = dx / distance * self.speed; self.velocityY = dy / distance * self.speed; } }; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; self.age++; }; self.isExpired = function () { return self.age >= self.lifeTime || self.x < -50 || self.x > 2098 || self.y < -50 || self.y > 2782; }; return self; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1.5; self.health = 1; self.maxHealth = 1; self.lastPlayerX = 0; self.lastPlayerY = 0; // Create health bar for enemy var healthBarWidth = enemyGraphics.width * 0.6; var healthBarBackground = LK.getAsset('buttonBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: healthBarWidth / 260, scaleY: 0.2 }); healthBarBackground.y = -enemyGraphics.height / 2 - 20; self.addChild(healthBarBackground); var healthBar = LK.getAsset('buyButton', { anchorX: 0.5, anchorY: 0.5, scaleX: healthBarWidth / 200, scaleY: 0.3 }); healthBar.y = -enemyGraphics.height / 2 - 20; healthBar.tint = 0x00ff00; self.addChild(healthBar); self.healthBar = healthBar; self.healthBarBackground = healthBarBackground; self.update = function () { if (player) { var dx = player.x - self.x; var dy = player.y - 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; } self.lastPlayerX = player.x; self.lastPlayerY = player.y; } }; self.takeDamage = function (damage) { damage = damage || 1; self.health -= damage; // Update health bar var healthPercent = self.health / self.maxHealth; self.healthBar.scaleX = self.healthBarBackground.width * healthPercent / 200; if (healthPercent > 0.5) { self.healthBar.tint = 0x00ff00; } else if (healthPercent > 0.25) { self.healthBar.tint = 0xffff00; } else { self.healthBar.tint = 0xff0000; } if (self.health <= 0) { LK.effects.flashObject(self, 0xFFFFFF, 200); return true; } return false; }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); // Create all directional graphics self.playerGraphicsUp = self.attachAsset('player_up', { anchorX: 0.5, anchorY: 0.5 }); self.playerGraphicsDown = self.attachAsset('player_down', { anchorX: 0.5, anchorY: 0.5, visible: false }); self.playerGraphicsLeft = self.attachAsset('player_left', { anchorX: 0.5, anchorY: 0.5, visible: false }); self.playerGraphicsRight = self.attachAsset('player_right', { anchorX: 0.5, anchorY: 0.5, visible: false }); self.currentDirection = 'up'; self.health = 100; self.maxHealth = 100; self.speed = 4; self.ammunition = 30; self.maxAmmo = 30; self.isReloading = false; self.reloadTime = 2000; self.setDirection = function (direction) { // Hide all graphics first self.playerGraphicsUp.visible = false; self.playerGraphicsDown.visible = false; self.playerGraphicsLeft.visible = false; self.playerGraphicsRight.visible = false; // Show the correct direction switch (direction) { case 'up': self.playerGraphicsUp.visible = true; break; case 'down': self.playerGraphicsDown.visible = true; break; case 'left': self.playerGraphicsLeft.visible = true; break; case 'right': self.playerGraphicsRight.visible = true; break; } self.currentDirection = direction; }; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.health = 0; LK.effects.flashScreen(0xFF0000, 1000); LK.showGameOver(); } else { LK.effects.flashObject(self, 0xFF0000, 300); } }; self.reload = function () { if (!self.isReloading && self.ammunition < self.maxAmmo) { self.isReloading = true; LK.getSound('reload').play(); LK.setTimeout(function () { self.ammunition = self.maxAmmo; self.isReloading = false; }, self.reloadTime); } }; self.canShoot = function () { return self.ammunition > 0 && !self.isReloading; }; self.shoot = function () { if (self.canShoot()) { self.ammunition--; if (self.ammunition === 0) { self.reload(); } return true; } return false; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2C3E50 }); /**** * Game Code ****/ var player; var enemies = []; var bullets = []; var enemySpawnTimer = 0; var enemySpawnRate = 180; var gameStarted = false; var lastTapTime = 0; var tapCooldown = 150; var mouseX = 2048 / 2; var mouseY = 2732 / 2; var bosses = []; var lastBossScore = 0; var bossActive = false; var currentWeapon = 'shotgun'; var weaponStats = { shotgun: { damage: 2, fireRate: 20, name: 'Shotgun', cost: 20 }, smg: { damage: 1, fireRate: 25, name: 'SMG', cost: 100 }, sniper: { damage: 5, fireRate: 60, name: 'Sniper', cost: 100 } }; var weaponOwned = { shotgun: true, smg: false, sniper: false }; var lastShotTime = 0; var isShooting = false; var shootingInterval = null; var buyConfirmationActive = false; var pendingWeapon = null; var buyConfirmationGUI = null; // UI Elements var healthText = new Text2('Health: 100', { size: 60, fill: 0xFFFFFF }); healthText.anchor.set(0, 0); LK.gui.topLeft.addChild(healthText); healthText.x = 120; healthText.y = 50; var ammoText = new Text2('Ammo: 30/30', { size: 60, fill: 0xFFFFFF }); ammoText.anchor.set(0, 0); LK.gui.topLeft.addChild(ammoText); ammoText.x = 120; ammoText.y = 120; var scoreText = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // High Score display in top right var highScore = storage.highScore || 0; var highScoreText = new Text2('High Score: ' + highScore, { size: 60, fill: 0xFFD700 }); highScoreText.anchor.set(1, 0); LK.gui.topRight.addChild(highScoreText); highScoreText.x = -20; highScoreText.y = 20; // +10 Score button below score text var scoreButtonBackground = LK.getAsset('buttonBackground', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); scoreButtonBackground.y = 140; LK.gui.top.addChild(scoreButtonBackground); var scoreButton = new Text2('+10 Score', { size: 60, fill: 0x00FF00 }); scoreButton.anchor.set(0.5, 0); LK.gui.top.addChild(scoreButton); scoreButton.y = 100; // Add game background var gameBackground = LK.getAsset('gameBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChild(gameBackground); // Initialize player player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 / 2; // Movement controls var movementKeys = { up: false, down: false, left: false, right: false }; // Create virtual joystick areas for mobile var moveUpArea = LK.getAsset('player_up', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3, scaleX: 2, scaleY: 1 }); moveUpArea.x = 200; moveUpArea.y = 2400; game.addChild(moveUpArea); var moveDownArea = LK.getAsset('player_up', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3, scaleX: 2, scaleY: 1 }); moveDownArea.x = 200; moveDownArea.y = 2600; game.addChild(moveDownArea); var moveLeftArea = LK.getAsset('player_up', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3, scaleX: 1, scaleY: 2 }); moveLeftArea.x = 100; moveLeftArea.y = 2500; game.addChild(moveLeftArea); var moveRightArea = LK.getAsset('player_up', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3, scaleX: 1, scaleY: 2 }); moveRightArea.x = 300; moveRightArea.y = 2500; game.addChild(moveRightArea); // Movement control handlers moveUpArea.down = function () { movementKeys.up = true; }; moveUpArea.up = function () { movementKeys.up = false; }; moveDownArea.down = function () { movementKeys.down = true; }; moveDownArea.up = function () { movementKeys.down = false; }; moveLeftArea.down = function () { movementKeys.left = true; }; moveLeftArea.up = function () { movementKeys.left = false; }; moveRightArea.down = function () { movementKeys.right = true; }; moveRightArea.up = function () { movementKeys.right = false; }; // Add weapon area background var weaponAreaBackground = LK.getAsset('buyBackground', { anchorX: 0.5, anchorY: 0.5, x: 1900, y: 1350, scaleX: 0.8, scaleY: 1.2, alpha: 0.7 }); game.addChild(weaponAreaBackground); // Add weapon selection buttons in right middle area var shotgunButton = LK.getAsset('shotgun', { anchorX: 0.5, anchorY: 0.5, x: 1900, y: 1200, alpha: 1.0 }); game.addChild(shotgunButton); var smgButton = LK.getAsset('smg', { anchorX: 0.5, anchorY: 0.5, x: 1900, y: 1350, alpha: 0.6 }); game.addChild(smgButton); var sniperButton = LK.getAsset('sniper', { anchorX: 0.5, anchorY: 0.5, x: 1900, y: 1500, alpha: 0.6 }); game.addChild(sniperButton); // Initialize weapon button states updateWeaponButtons(); // Weapon selection handlers shotgunButton.down = function () { if (weaponOwned.shotgun) { currentWeapon = 'shotgun'; shotgunButton.alpha = 1.0; smgButton.alpha = 0.6; sniperButton.alpha = 0.6; } else { showBuyConfirmation('shotgun'); } }; smgButton.down = function () { if (weaponOwned.smg) { currentWeapon = 'smg'; shotgunButton.alpha = 0.6; smgButton.alpha = 1.0; sniperButton.alpha = 0.6; } else { showBuyConfirmation('smg'); } }; sniperButton.down = function () { if (weaponOwned.sniper) { currentWeapon = 'sniper'; shotgunButton.alpha = 0.6; smgButton.alpha = 0.6; sniperButton.alpha = 1.0; } else { showBuyConfirmation('sniper'); } }; function showBuyConfirmation(weaponType) { if (buyConfirmationActive) return; var weaponCost = weaponStats[weaponType].cost; var canAfford = LK.getScore() >= weaponCost; buyConfirmationActive = true; pendingWeapon = weaponType; // Create buy confirmation GUI buyConfirmationGUI = new Container(); LK.gui.center.addChild(buyConfirmationGUI); // Background var background = LK.getAsset('buyBackground', { anchorX: 0.5, anchorY: 0.5, alpha: 0.9 }); buyConfirmationGUI.addChild(background); // Title text var titleText = new Text2('Buy ' + weaponStats[weaponType].name + '?', { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.y = -70; buyConfirmationGUI.addChild(titleText); // Cost text var costText = new Text2('Cost: ' + weaponCost + ' Score', { size: 50, fill: 0xFFD700 }); costText.anchor.set(0.5, 0.5); costText.y = -20; buyConfirmationGUI.addChild(costText); // Warning text for insufficient funds if (!canAfford) { var warningText = new Text2('Para yetersiz', { size: 45, fill: 0xFF4444 }); warningText.anchor.set(0.5, 0.5); warningText.y = 30; buyConfirmationGUI.addChild(warningText); } // Buy button var buyButton = LK.getAsset('buyButton', { anchorX: 0.5, anchorY: 0.5, y: 80 }); if (!canAfford) { buyButton.tint = 0x666666; buyButton.alpha = 0.5; } buyConfirmationGUI.addChild(buyButton); var buyText = new Text2('BUY', { size: 40, fill: canAfford ? 0xFFFFFF : 0x999999 }); buyText.anchor.set(0.5, 0.5); buyText.y = 80; buyConfirmationGUI.addChild(buyText); // Buy button handler buyButton.down = function () { if (LK.getScore() >= weaponCost) { LK.setScore(LK.getScore() - weaponCost); scoreText.setText('Score: ' + LK.getScore()); weaponOwned[pendingWeapon] = true; currentWeapon = pendingWeapon; updateWeaponButtons(); } hideBuyConfirmation(); }; // Cancel button (background click) background.down = function () { hideBuyConfirmation(); }; } function hideBuyConfirmation() { if (buyConfirmationGUI) { buyConfirmationGUI.destroy(); buyConfirmationGUI = null; } buyConfirmationActive = false; pendingWeapon = null; } function updateWeaponButtons() { // Update shotgun button if (weaponOwned.shotgun) { shotgunButton.alpha = currentWeapon === 'shotgun' ? 1.0 : 0.6; shotgunButton.tint = 0xFFFFFF; } else { shotgunButton.alpha = 0.8; shotgunButton.tint = 0xFF4444; } // Update SMG button if (weaponOwned.smg) { smgButton.alpha = currentWeapon === 'smg' ? 1.0 : 0.6; smgButton.tint = 0xFFFFFF; } else { smgButton.alpha = 0.8; smgButton.tint = 0xFF4444; } // Update sniper button if (weaponOwned.sniper) { sniperButton.alpha = currentWeapon === 'sniper' ? 1.0 : 0.6; sniperButton.tint = 0xFFFFFF; } else { sniperButton.alpha = 0.8; sniperButton.tint = 0xFF4444; } } function spawnEnemy() { var enemy = new Enemy(); // Calculate speed multiplier based on score (10% faster every 10 points) var speedMultiplier = 1 + Math.floor(LK.getScore() / 10) * 0.1; enemy.speed = enemy.speed * speedMultiplier; var side = Math.floor(Math.random() * 4); switch (side) { case 0: // Top enemy.x = Math.random() * 2048; enemy.y = -25; break; case 1: // Right enemy.x = 2073; enemy.y = Math.random() * 2732; break; case 2: // Bottom enemy.x = Math.random() * 2048; enemy.y = 2757; break; case 3: // Left enemy.x = -25; enemy.y = Math.random() * 2732; break; } enemies.push(enemy); game.addChild(enemy); } function spawnBoss() { var currentScore = LK.getScore(); var bossType = 25; // Default boss if (currentScore >= 100) { bossType = 100; } else if (currentScore >= 75) { bossType = 75; } else if (currentScore >= 50) { bossType = 50; } var boss = new Boss(bossType); var side = Math.floor(Math.random() * 4); switch (side) { case 0: // Top boss.x = Math.random() * 2048; boss.y = -50; break; case 1: // Right boss.x = 2098; boss.y = Math.random() * 2732; break; case 2: // Bottom boss.x = Math.random() * 2048; boss.y = 2782; break; case 3: // Left boss.x = -50; boss.y = Math.random() * 2732; break; } bosses.push(boss); game.addChild(boss); bossActive = true; LK.playMusic('bossMusic'); } function fireBullet(targetX, targetY) { if (player.shoot()) { if (currentWeapon === 'shotgun') { // Fire 3 bullets with spread for shotgun for (var i = 0; i < 3; i++) { var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; // Calculate angle to target var dx = targetX - player.x; var dy = targetY - player.y; var baseAngle = Math.atan2(dy, dx); // Add spread (-0.3, 0, +0.3 radians) var spreadAngle = baseAngle + (i - 1) * 0.3; var spreadTargetX = player.x + Math.cos(spreadAngle) * 500; var spreadTargetY = player.y + Math.sin(spreadAngle) * 500; bullet.setDirection(spreadTargetX, spreadTargetY); bullets.push(bullet); game.addChild(bullet); } } else if (currentWeapon === 'sniper') { // Sniper bullet with penetration var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullet.setDirection(targetX, targetY); bullet.isPenetrating = true; bullet.penetrationCount = 0; bullet.maxPenetration = 3; bullet.lifeTime = 360; // 3x longer range for sniper bullets.push(bullet); game.addChild(bullet); } else { // Regular bullet for SMG var bullet = new Bullet(); bullet.x = player.x; bullet.y = player.y; bullet.setDirection(targetX, targetY); bullets.push(bullet); game.addChild(bullet); } LK.getSound('shoot').play(); } } // Mouse/touch tracking for player direction game.move = function (x, y, obj) { mouseX = x; mouseY = y; // Calculate direction from player to mouse var dx = mouseX - player.x; var dy = mouseY - player.y; // Determine which direction is dominant if (Math.abs(dx) > Math.abs(dy)) { // Horizontal movement is dominant if (dx > 0) { player.setDirection('right'); } else { player.setDirection('left'); } } else { // Vertical movement is dominant if (dy > 0) { player.setDirection('down'); } else { player.setDirection('up'); } } }; // Score button click handler scoreButton.down = function (x, y, obj) { LK.setScore(LK.getScore() + 10); scoreText.setText('Score: ' + LK.getScore()); // Update high score if current score is higher if (LK.getScore() > highScore) { highScore = LK.getScore(); storage.highScore = highScore; highScoreText.setText('High Score: ' + highScore); } }; // Score button background click handler scoreButtonBackground.down = function (x, y, obj) { LK.setScore(LK.getScore() + 10); scoreText.setText('Score: ' + LK.getScore()); // Update high score if current score is higher if (LK.getScore() > highScore) { highScore = LK.getScore(); storage.highScore = highScore; highScoreText.setText('High Score: ' + highScore); } }; // Shooting controls game.down = function (x, y, obj) { var currentTime = Date.now(); var weaponFireRate = weaponStats[currentWeapon].fireRate; mouseX = x; mouseY = y; // Update direction when shooting var dx = mouseX - player.x; var dy = mouseY - player.y; if (Math.abs(dx) > Math.abs(dy)) { if (dx > 0) { player.setDirection('right'); } else { player.setDirection('left'); } } else { if (dy > 0) { player.setDirection('down'); } else { player.setDirection('up'); } } if (currentWeapon === 'smg') { // Start continuous firing for SMG isShooting = true; if (currentTime - lastShotTime > weaponFireRate) { fireBullet(x, y); lastShotTime = currentTime; } if (!shootingInterval) { shootingInterval = LK.setInterval(function () { if (isShooting && player.canShoot()) { fireBullet(mouseX, mouseY); } }, weaponFireRate); } } else { // Single shot for shotgun and sniper if (currentTime - lastShotTime > weaponFireRate) { fireBullet(x, y); lastShotTime = currentTime; } } }; // Add mouse up handler to stop SMG firing game.up = function (x, y, obj) { isShooting = false; if (shootingInterval) { LK.clearInterval(shootingInterval); shootingInterval = null; } }; // Main game loop game.update = function () { if (!player) return; // Player movement if (movementKeys.up && player.y > 30) { player.y -= player.speed; } if (movementKeys.down && player.y < 2702) { player.y += player.speed; } if (movementKeys.left && player.x > 30) { player.x -= player.speed; } if (movementKeys.right && player.x < 2018) { player.x += player.speed; } // Spawn enemies enemySpawnTimer++; if (enemySpawnTimer >= enemySpawnRate) { spawnEnemy(); enemySpawnTimer = 0; // Increase difficulty over time if (enemySpawnRate > 60) { enemySpawnRate--; } } // Check for boss spawn every 25 points if (LK.getScore() > 0 && LK.getScore() % 25 === 0 && LK.getScore() !== lastBossScore && !bossActive) { spawnBoss(); lastBossScore = LK.getScore(); } // Update bullets for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; if (bullet.isExpired()) { bullet.destroy(); bullets.splice(i, 1); continue; } // Check bullet-enemy collisions for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (bullet.intersects(enemy)) { var damage = weaponStats[currentWeapon].damage; if (enemy.takeDamage(damage)) { LK.setScore(LK.getScore() + 1); scoreText.setText('Score: ' + LK.getScore()); // Update high score if current score is higher if (LK.getScore() > highScore) { highScore = LK.getScore(); storage.highScore = highScore; highScoreText.setText('High Score: ' + highScore); } LK.getSound('enemyHit').play(); enemy.destroy(); enemies.splice(j, 1); } // Handle bullet penetration for sniper if (bullet.isPenetrating && bullet.penetrationCount < bullet.maxPenetration) { bullet.penetrationCount++; } else { bullet.destroy(); bullets.splice(i, 1); } break; } } // Check bullet-boss collisions for (var b = bosses.length - 1; b >= 0; b--) { var boss = bosses[b]; if (bullet.intersects(boss)) { var damage = weaponStats[currentWeapon].damage; if (boss.takeDamage(damage)) { LK.setScore(LK.getScore() + 10); scoreText.setText('Score: ' + LK.getScore()); // Update high score if current score is higher if (LK.getScore() > highScore) { highScore = LK.getScore(); storage.highScore = highScore; highScoreText.setText('High Score: ' + highScore); } LK.getSound('bossDeath').play(); boss.destroy(); bosses.splice(b, 1); bossActive = false; LK.stopMusic(); } // Handle bullet penetration for sniper if (bullet.isPenetrating && bullet.penetrationCount < bullet.maxPenetration) { bullet.penetrationCount++; } else { bullet.destroy(); bullets.splice(i, 1); } break; } } } // Check player-enemy collisions for (var k = enemies.length - 1; k >= 0; k--) { var enemy = enemies[k]; if (player.intersects(enemy)) { player.takeDamage(100); break; } } // Check player-boss collisions for (var m = bosses.length - 1; m >= 0; m--) { var boss = bosses[m]; if (player.intersects(boss)) { player.takeDamage(100); break; } } // Update UI healthText.setText('Health: ' + player.health); if (player.isReloading) { ammoText.setText('Reloading...'); } else { ammoText.setText('Ammo: ' + player.ammunition + '/' + player.maxAmmo); } };
===================================================================
--- original.js
+++ change.js
@@ -461,8 +461,19 @@
};
moveRightArea.up = function () {
movementKeys.right = false;
};
+// Add weapon area background
+var weaponAreaBackground = LK.getAsset('buyBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1900,
+ y: 1350,
+ scaleX: 0.8,
+ scaleY: 1.2,
+ alpha: 0.7
+});
+game.addChild(weaponAreaBackground);
// Add weapon selection buttons in right middle area
var shotgunButton = LK.getAsset('shotgun', {
anchorX: 0.5,
anchorY: 0.5,
@@ -522,9 +533,9 @@
};
function showBuyConfirmation(weaponType) {
if (buyConfirmationActive) return;
var weaponCost = weaponStats[weaponType].cost;
- if (LK.getScore() < weaponCost) return;
+ var canAfford = LK.getScore() >= weaponCost;
buyConfirmationActive = true;
pendingWeapon = weaponType;
// Create buy confirmation GUI
buyConfirmationGUI = new Container();
@@ -541,28 +552,42 @@
size: 60,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
- titleText.y = -50;
+ titleText.y = -70;
buyConfirmationGUI.addChild(titleText);
// Cost text
var costText = new Text2('Cost: ' + weaponCost + ' Score', {
size: 50,
fill: 0xFFD700
});
costText.anchor.set(0.5, 0.5);
- costText.y = 0;
+ costText.y = -20;
buyConfirmationGUI.addChild(costText);
+ // Warning text for insufficient funds
+ if (!canAfford) {
+ var warningText = new Text2('Para yetersiz', {
+ size: 45,
+ fill: 0xFF4444
+ });
+ warningText.anchor.set(0.5, 0.5);
+ warningText.y = 30;
+ buyConfirmationGUI.addChild(warningText);
+ }
// Buy button
var buyButton = LK.getAsset('buyButton', {
anchorX: 0.5,
anchorY: 0.5,
y: 80
});
+ if (!canAfford) {
+ buyButton.tint = 0x666666;
+ buyButton.alpha = 0.5;
+ }
buyConfirmationGUI.addChild(buyButton);
var buyText = new Text2('BUY', {
size: 40,
- fill: 0xFFFFFF
+ fill: canAfford ? 0xFFFFFF : 0x999999
});
buyText.anchor.set(0.5, 0.5);
buyText.y = 80;
buyConfirmationGUI.addChild(buyText);
@@ -590,11 +615,32 @@
buyConfirmationActive = false;
pendingWeapon = null;
}
function updateWeaponButtons() {
- shotgunButton.alpha = weaponOwned.shotgun ? currentWeapon === 'shotgun' ? 1.0 : 0.6 : 0.3;
- smgButton.alpha = weaponOwned.smg ? currentWeapon === 'smg' ? 1.0 : 0.6 : 0.3;
- sniperButton.alpha = weaponOwned.sniper ? currentWeapon === 'sniper' ? 1.0 : 0.6 : 0.3;
+ // Update shotgun button
+ if (weaponOwned.shotgun) {
+ shotgunButton.alpha = currentWeapon === 'shotgun' ? 1.0 : 0.6;
+ shotgunButton.tint = 0xFFFFFF;
+ } else {
+ shotgunButton.alpha = 0.8;
+ shotgunButton.tint = 0xFF4444;
+ }
+ // Update SMG button
+ if (weaponOwned.smg) {
+ smgButton.alpha = currentWeapon === 'smg' ? 1.0 : 0.6;
+ smgButton.tint = 0xFFFFFF;
+ } else {
+ smgButton.alpha = 0.8;
+ smgButton.tint = 0xFF4444;
+ }
+ // Update sniper button
+ if (weaponOwned.sniper) {
+ sniperButton.alpha = currentWeapon === 'sniper' ? 1.0 : 0.6;
+ sniperButton.tint = 0xFFFFFF;
+ } else {
+ sniperButton.alpha = 0.8;
+ sniperButton.tint = 0xFF4444;
+ }
}
function spawnEnemy() {
var enemy = new Enemy();
// Calculate speed multiplier based on score (10% faster every 10 points)
terrorist sketch 1. In-Game asset. 2d. High contrast. No shadows
Bullet. In-Game asset. 2d. High contrast. No shadows
boss sketch ballistic shield. In-Game asset. 2d. High contrast. No shadows
angry devil golem holding a big shield on right hand. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
red big monster dragon sketch. In-Game asset. 2d. High contrast. No shadows
god sketch. 3d model In-Game asset. 2d. High contrast. No shadows
dust 2 dark. In-Game asset. 2d. High contrast. No shadows
black smg icon with white stroke. In-Game asset. 2d. High contrast. No shadows
black sniper icon with white stroke. In-Game asset. 2d. High contrast. No shadows
black shotgun icon with white stroke. In-Game asset. 2d. High contrast. No shadows