User prompt
Marketteki eşyalardaki yeşil şeyleri kaldır
User prompt
Marketteki eşyaların arkasına "Tahta" eşyasını koy
User prompt
Önceki bitiş ekranını geri getir
User prompt
Sağ üstteki her şeyi kaldır
User prompt
Sağ üstteki "PAUSE" yazısını kaldır
User prompt
Skor ve COIN bilgilerinin arkasında "Tahta" eşyası olsun
User prompt
Oyunu durdurma butonuna bastığımızda bir menü açılsın ve menüde 3 seçenek olsun; "RESTART", "CONTINUE", "MARKET".
User prompt
Oyun durdurulduğunda bitiş ekranı gelsin
User prompt
Oyun durdurulduğunda karşımıza bir menü çıksın
User prompt
Oyunu durdurduğumuz menüye tekrar başlama ve markete erişme butonları ekle
User prompt
Oyun esnasında oyunu durdurabileceğimiz bir buton ekle
User prompt
Markette satılan eşyaların arkasına "Tahta" eşyasını koy
User prompt
Marketteki eşyaların arkasına "Tahta" eşyasını koy
User prompt
Dalga, mermi, can bilgilerinin arkasına "Tahta" eşyasını koy
User prompt
Dalga, mermi ve can bilgilerinin arkasındaki tabaka ahşap temasında olsun
User prompt
Dalga, mermi ve can bilgilerinin arkasında bir tabaka olsun
User prompt
Can, mermi, dalga bilgilerini aşağıya taşı
User prompt
Can, mermi, dalga bilgilerini aşağıda göster
User prompt
Marketten alınan ögeler 2 kat değil %50 artsın
User prompt
Market fiyatları her el kaldığı yerden devam etsin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Zombilerin verdiği zarar her 15 dalgada bir artsın
User prompt
Zombilerin canı her 5 dalgada 1 artsın
User prompt
Her 10 dalga bir zombilerin hızı artsın
User prompt
Her satın alımda fiyat 2 katına çıksın
User prompt
Marketteki eşyalar her satın alımda daha da pahalansın
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
healthUpgrades: 0,
ammoUpgrades: 0,
speedUpgrades: 0,
coins: 0,
healthUpgradeCost: 200,
ammoUpgradeCost: 100,
speedUpgradeCost: 300
});
/****
* Classes
****/
var Bullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.dx = 0;
self.dy = 0;
self.lifetime = 120;
self.update = function () {
self.x += self.dx * self.speed;
self.y += self.dy * self.speed;
// Rotate bullet to face movement direction
graphics.rotation = Math.atan2(self.dy, self.dx);
self.lifetime--;
if (self.lifetime <= 0 || self.isOutOfBounds()) {
self.remove();
return;
}
for (var i = 0; i < zombies.length; i++) {
var zombie = zombies[i];
if (self.intersects(zombie)) {
zombie.takeDamage(1);
self.remove();
return;
}
}
};
self.isOutOfBounds = function () {
return self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732;
};
self.remove = function () {
var index = bullets.indexOf(self);
if (index > -1) {
bullets.splice(index, 1);
}
self.destroy();
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.ammo = 30;
self.maxAmmo = 30;
self.shootCooldown = 0;
self.baseShootCooldown = 10;
self.update = function () {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
};
self.takeDamage = function (damage) {
self.health -= damage;
LK.getSound('playerHit').play();
if (self.health <= 0) {
self.health = 0;
LK.effects.flashScreen(0xff0000, 1000);
showCustomGameOver();
} else {
LK.effects.flashObject(self, 0xff0000, 200);
}
};
self.canShoot = function () {
return self.ammo > 0 && self.shootCooldown <= 0;
};
self.shoot = function () {
if (self.canShoot()) {
self.ammo--;
self.shootCooldown = self.baseShootCooldown;
return true;
}
return false;
};
return self;
});
var Zombie = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 1 + Math.random() * 0.5;
self.health = 1;
self.damage = 10;
self.lastPlayerCollision = false;
self.update = function () {
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;
}
var currentCollision = self.intersects(player);
if (!self.lastPlayerCollision && currentCollision) {
player.takeDamage(self.damage);
// Zombie dies from collision but doesn't give coins
self.health = 0;
LK.effects.flashObject(self, 0xffffff, 100);
var index = zombies.indexOf(self);
if (index > -1) {
zombies.splice(index, 1);
}
self.destroy();
}
self.lastPlayerCollision = currentCollision;
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
LK.effects.flashObject(self, 0xffffff, 100);
LK.setScore(LK.getScore() + 10);
storage.coins += 10;
LK.getSound('zombieHit').play();
var index = zombies.indexOf(self);
if (index > -1) {
zombies.splice(index, 1);
}
self.destroy();
}
};
return self;
});
var Zombie2 = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('zombie2', {
anchorX: 0.5,
anchorY: 0.5
});
graphics.tint = 0xff6b6b; // Reddish tint to differentiate
self.speed = 1 + Math.random() * 0.5;
self.health = 1;
self.damage = 10;
self.lastPlayerCollision = false;
self.update = function () {
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;
}
var currentCollision = self.intersects(player);
if (!self.lastPlayerCollision && currentCollision) {
player.takeDamage(self.damage);
// Zombie dies from collision but doesn't give coins
self.health = 0;
LK.effects.flashObject(self, 0xffffff, 100);
var index = zombies.indexOf(self);
if (index > -1) {
zombies.splice(index, 1);
}
self.destroy();
}
self.lastPlayerCollision = currentCollision;
};
self.takeDamage = function (damage) {
self.health -= damage;
if (self.health <= 0) {
LK.effects.flashObject(self, 0xffffff, 100);
LK.setScore(LK.getScore() + 10);
storage.coins += 10;
LK.getSound('zombieHit').play();
var index = zombies.indexOf(self);
if (index > -1) {
zombies.splice(index, 1);
}
self.destroy();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2d2d2d
});
/****
* Game Code
****/
var arena = game.attachAsset('arena', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 0.15,
scaleY: 0.15
});
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
player.scaleX = 1.0;
player.scaleY = 1.0;
// Apply stored upgrades
player.maxHealth = 100 + storage.healthUpgrades * 20;
player.health = player.maxHealth;
player.maxAmmo = 30 + storage.ammoUpgrades * 10;
player.ammo = player.maxAmmo;
player.baseShootCooldown = Math.max(1, 10 - storage.speedUpgrades);
var zombies = [];
var bullets = [];
var waveNumber = 1;
var zombiesInWave = 5;
var zombiesSpawned = 0;
var spawnTimer = 0;
var gameOverScreen = null;
var showingGameOver = false;
var showingMarket = false;
var marketPanel = null;
var isPaused = false;
var pausePanel = null;
// Upgrade costs that increase with each purchase - loaded from storage
var healthUpgradeCost = storage.healthUpgradeCost;
var ammoUpgradeCost = storage.ammoUpgradeCost;
var speedUpgradeCost = storage.speedUpgradeCost;
var healthBackground = LK.getAsset('Tahta', {
width: 300,
height: 60,
anchorX: 0,
anchorY: 1,
x: 120,
y: 0
});
healthBackground.alpha = 0.7;
LK.gui.bottomLeft.addChild(healthBackground);
var healthBar = new Text2('Health: 100', {
size: 60,
fill: 0xFF0000
});
healthBar.anchor.set(0, 1);
healthBar.x = 120; // Move away from bottom-left corner
LK.gui.bottomLeft.addChild(healthBar);
var ammoBackground = LK.getAsset('Tahta', {
width: 300,
height: 60,
anchorX: 0,
anchorY: 1,
x: 120,
y: -70
});
ammoBackground.alpha = 0.7;
LK.gui.bottomLeft.addChild(ammoBackground);
var ammoDisplay = new Text2('Ammo: 30', {
size: 60,
fill: 0x00FF00
});
ammoDisplay.anchor.set(0, 1);
ammoDisplay.x = 120; // Move away from bottom-left corner
ammoDisplay.y = -70;
LK.gui.bottomLeft.addChild(ammoDisplay);
var waveBackground = LK.getAsset('Tahta', {
width: 300,
height: 60,
anchorX: 0,
anchorY: 1,
x: 120,
y: -140
});
waveBackground.alpha = 0.7;
LK.gui.bottomLeft.addChild(waveBackground);
var waveInfo = new Text2('Wave: 1', {
size: 60,
fill: 0xFFFF00
});
waveInfo.anchor.set(0, 1);
waveInfo.x = 120; // Move away from bottom-left corner
waveInfo.y = -140;
LK.gui.bottomLeft.addChild(waveInfo);
var scoreDisplay = new Text2('SCORE: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreDisplay);
var coinDisplay = new Text2('COIN: ' + storage.coins, {
size: 60,
fill: 0xFFD700
});
coinDisplay.anchor.set(0.5, 0);
coinDisplay.y = 90;
LK.gui.top.addChild(coinDisplay);
var waveDisplay = new Text2('Wave: 1', {
size: 60,
fill: 0xFFFF00
});
waveDisplay.anchor.set(1, 0);
LK.gui.topRight.addChild(waveDisplay);
var pauseButton = LK.getAsset('marketButton', {
width: 200,
height: 80,
anchorX: 1,
anchorY: 0,
x: 0,
y: 80
});
pauseButton.tint = 0xFF9800;
LK.gui.topRight.addChild(pauseButton);
var pauseText = new Text2('PAUSE', {
size: 50,
fill: 0xFFFFFF
});
pauseText.anchor.set(1, 0);
pauseText.x = -10;
pauseText.y = 105;
LK.gui.topRight.addChild(pauseText);
function showCustomGameOver() {
if (showingGameOver) return;
showingGameOver = true;
gameOverScreen = new Container();
// Semi-transparent background
var background = LK.getAsset('arena', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 3,
scaleY: 3
});
background.alpha = 0.8;
background.tint = 0x000000;
gameOverScreen.addChild(background);
// Game Over text
var gameOverText = new Text2('GAME OVER', {
size: 120,
fill: 0xFF0000
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = 2048 / 2;
gameOverText.y = 2732 / 2 - 200;
gameOverScreen.addChild(gameOverText);
// Final score
var finalScoreText = new Text2('Final SCORE: ' + LK.getScore(), {
size: 80,
fill: 0xFFFFFF
});
finalScoreText.anchor.set(0.5, 0.5);
finalScoreText.x = 2048 / 2;
finalScoreText.y = 2732 / 2 - 100;
gameOverScreen.addChild(finalScoreText);
// Market button
var marketButton = LK.getAsset('marketButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 50
});
gameOverScreen.addChild(marketButton);
// Market button text
var marketText = new Text2('MARKET', {
size: 60,
fill: 0xFFFFFF
});
marketText.anchor.set(0.5, 0.5);
marketText.x = 2048 / 2;
marketText.y = 2732 / 2 + 50;
gameOverScreen.addChild(marketText);
// Restart button
var restartButton = LK.getAsset('marketButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 150
});
restartButton.tint = 0x2196F3;
gameOverScreen.addChild(restartButton);
// Restart button text
var restartText = new Text2('RESTART', {
size: 60,
fill: 0xFFFFFF
});
restartText.anchor.set(0.5, 0.5);
restartText.x = 2048 / 2;
restartText.y = 2732 / 2 + 150;
gameOverScreen.addChild(restartText);
game.addChild(gameOverScreen);
}
function hideGameOver() {
if (gameOverScreen) {
gameOverScreen.destroy();
gameOverScreen = null;
}
showingGameOver = false;
}
function showMarket() {
if (showingMarket) return;
showingMarket = true;
marketPanel = new Container();
// Semi-transparent background
var background = LK.getAsset('arena', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 4,
scaleY: 4
});
background.alpha = 0.9;
background.tint = 0x000000;
marketPanel.addChild(background);
// Market title
var marketTitle = new Text2('MARKET', {
size: 140,
fill: 0xFFFFFF
});
marketTitle.anchor.set(0.5, 0.5);
marketTitle.x = 2048 / 2;
marketTitle.y = 2732 / 2 - 400;
marketPanel.addChild(marketTitle);
// Show current coins
var currentCoins = storage.coins;
var scoreText = new Text2('COIN: ' + storage.coins, {
size: 80,
fill: 0xFFD700
});
scoreText.anchor.set(0.5, 0.5);
scoreText.x = 2048 / 2;
scoreText.y = 2732 / 2 - 300;
marketPanel.addChild(scoreText);
// Health upgrade background
var healthUpgradeBackground = LK.getAsset('Tahta', {
width: 520,
height: 120,
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 150
});
healthUpgradeBackground.alpha = 0.7;
marketPanel.addChild(healthUpgradeBackground);
// Health upgrade
var healthUpgrade = LK.getAsset('marketButton', {
width: 500,
height: 100,
color: 0xFF6B6B,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 150
});
healthUpgrade.down = function (x, y, obj) {
if (storage.coins >= healthUpgradeCost) {
storage.coins -= healthUpgradeCost;
healthUpgradeCost = Math.floor(healthUpgradeCost * 1.5); // Increase cost by 50%
storage.healthUpgradeCost = healthUpgradeCost; // Save to storage
storage.healthUpgrades++;
player.maxHealth += 20;
player.health = Math.min(player.health + 20, player.maxHealth);
coinDisplay.setText('COIN: ' + storage.coins);
LK.getSound('coinPurchase').play();
hideMarket();
showMarket(); // Refresh market display
}
};
marketPanel.addChild(healthUpgrade);
var healthText = new Text2('Health +20 (' + healthUpgradeCost + ' COIN)', {
size: 65,
fill: 0xFFFFFF
});
healthText.anchor.set(0.5, 0.5);
healthText.x = 2048 / 2 - 100;
healthText.y = 2732 / 2 - 150;
marketPanel.addChild(healthText);
// Ammo upgrade background
var ammoUpgradeBackground = LK.getAsset('Tahta', {
width: 470,
height: 120,
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 50
});
ammoUpgradeBackground.alpha = 0.7;
marketPanel.addChild(ammoUpgradeBackground);
// Ammo upgrade
var ammoUpgrade = LK.getAsset('marketButton', {
width: 450,
height: 100,
color: 0x4ECDC4,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 50
});
ammoUpgrade.down = function (x, y, obj) {
if (storage.coins >= ammoUpgradeCost) {
storage.coins -= ammoUpgradeCost;
ammoUpgradeCost = Math.floor(ammoUpgradeCost * 1.5); // Increase cost by 50%
storage.ammoUpgradeCost = ammoUpgradeCost; // Save to storage
storage.ammoUpgrades++;
player.maxAmmo += 10;
player.ammo = Math.min(player.ammo + 10, player.maxAmmo);
coinDisplay.setText('COIN: ' + storage.coins);
LK.getSound('coinPurchase').play();
hideMarket();
showMarket(); // Refresh market display
}
};
marketPanel.addChild(ammoUpgrade);
var ammoText = new Text2('Ammo +10 (' + ammoUpgradeCost + ' COIN)', {
size: 65,
fill: 0xFFFFFF
});
ammoText.anchor.set(0.5, 0.5);
ammoText.x = 2048 / 2 - 100;
ammoText.y = 2732 / 2 - 50;
marketPanel.addChild(ammoText);
// Speed upgrade background
var speedUpgradeBackground = LK.getAsset('Tahta', {
width: 540,
height: 120,
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 50
});
speedUpgradeBackground.alpha = 0.7;
marketPanel.addChild(speedUpgradeBackground);
// Speed upgrade
var speedUpgrade = LK.getAsset('marketButton', {
width: 520,
height: 100,
color: 0x45B7D1,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 50
});
speedUpgrade.down = function (x, y, obj) {
if (storage.coins >= speedUpgradeCost) {
storage.coins -= speedUpgradeCost;
speedUpgradeCost = Math.floor(speedUpgradeCost * 1.5); // Increase cost by 50%
storage.speedUpgradeCost = speedUpgradeCost; // Save to storage
storage.speedUpgrades++;
player.baseShootCooldown = Math.max(1, player.baseShootCooldown - 1);
coinDisplay.setText('COIN: ' + storage.coins);
LK.getSound('coinPurchase').play();
hideMarket();
showMarket(); // Refresh market display
}
};
marketPanel.addChild(speedUpgrade);
var speedText = new Text2('Fire Rate +1 (' + speedUpgradeCost + ' COIN)', {
size: 65,
fill: 0xFFFFFF
});
speedText.anchor.set(0.5, 0.5);
speedText.x = 2048 / 2 - 100;
speedText.y = 2732 / 2 + 50;
marketPanel.addChild(speedText);
// Close button
var closeButton = LK.getAsset('marketButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 200
});
closeButton.tint = 0x666666;
closeButton.down = function (x, y, obj) {
hideMarket();
};
marketPanel.addChild(closeButton);
var closeText = new Text2('CLOSE', {
size: 80,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 2048 / 2;
closeText.y = 2732 / 2 + 200;
marketPanel.addChild(closeText);
game.addChild(marketPanel);
}
function hideMarket() {
if (marketPanel) {
marketPanel.destroy();
marketPanel = null;
}
showingMarket = false;
}
function showPause() {
if (isPaused) return;
isPaused = true;
pausePanel = new Container();
// Semi-transparent background
var background = LK.getAsset('arena', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 3,
scaleY: 3
});
background.alpha = 0.8;
background.tint = 0x000000;
pausePanel.addChild(background);
// Pause title
var pauseTitle = new Text2('PAUSED', {
size: 140,
fill: 0xFFFFFF
});
pauseTitle.anchor.set(0.5, 0.5);
pauseTitle.x = 2048 / 2;
pauseTitle.y = 2732 / 2 - 200;
pausePanel.addChild(pauseTitle);
// Resume button
var resumeButton = LK.getAsset('marketButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 - 50
});
resumeButton.tint = 0x4CAF50;
resumeButton.down = function (x, y, obj) {
hidePause();
};
pausePanel.addChild(resumeButton);
var resumeText = new Text2('RESUME', {
size: 60,
fill: 0xFFFFFF
});
resumeText.anchor.set(0.5, 0.5);
resumeText.x = 2048 / 2;
resumeText.y = 2732 / 2 - 50;
pausePanel.addChild(resumeText);
// Market button
var marketButton = LK.getAsset('marketButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 50
});
pausePanel.addChild(marketButton);
var marketText = new Text2('MARKET', {
size: 60,
fill: 0xFFFFFF
});
marketText.anchor.set(0.5, 0.5);
marketText.x = 2048 / 2;
marketText.y = 2732 / 2 + 50;
pausePanel.addChild(marketText);
// Restart button
var restartButton = LK.getAsset('marketButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2 + 150
});
restartButton.tint = 0x2196F3;
pausePanel.addChild(restartButton);
var restartText = new Text2('RESTART', {
size: 60,
fill: 0xFFFFFF
});
restartText.anchor.set(0.5, 0.5);
restartText.x = 2048 / 2;
restartText.y = 2732 / 2 + 150;
pausePanel.addChild(restartText);
game.addChild(pausePanel);
}
function hidePause() {
if (pausePanel) {
pausePanel.destroy();
pausePanel = null;
}
isPaused = false;
}
function restartGame() {
hideGameOver();
// Reset player with upgraded stats
player.maxHealth = 100 + storage.healthUpgrades * 20;
player.health = player.maxHealth;
player.maxAmmo = 30 + storage.ammoUpgrades * 10;
player.ammo = player.maxAmmo;
player.baseShootCooldown = Math.max(1, 10 - storage.speedUpgrades);
player.x = 2048 / 2;
player.y = 2732 / 2;
// Clear all entities
for (var i = 0; i < zombies.length; i++) {
zombies[i].destroy();
}
zombies = [];
for (var i = 0; i < bullets.length; i++) {
bullets[i].destroy();
}
bullets = [];
// Reset game state
waveNumber = 1;
zombiesInWave = 5;
zombiesSpawned = 0;
spawnTimer = 0;
LK.setScore(0);
}
function spawnZombie() {
var zombie = Math.random() < 0.5 ? new Zombie() : new Zombie2();
// Define spawn locations around the arena edges
var spawnLocations = [{
x: Math.random() * 2048,
y: 100
},
// Top edge
{
x: Math.random() * 2048,
y: 2632
},
// Bottom edge
{
x: 100,
y: Math.random() * 2732
},
// Left edge
{
x: 1948,
y: Math.random() * 2732
},
// Right edge
{
x: 300,
y: 300
},
// Top-left corner
{
x: 1748,
y: 300
},
// Top-right corner
{
x: 300,
y: 2432
},
// Bottom-left corner
{
x: 1748,
y: 2432
} // Bottom-right corner
];
// Pick a random spawn location from the predefined spots
var spawnIndex = Math.floor(Math.random() * spawnLocations.length);
var spawnPoint = spawnLocations[spawnIndex];
zombie.x = spawnPoint.x;
zombie.y = spawnPoint.y;
// Increase zombie health every 5 waves
zombie.health = 1 + Math.floor(waveNumber / 5);
// Increase zombie speed every 10 waves
var speedBonus = Math.floor(waveNumber / 10) * 0.5;
zombie.speed += speedBonus;
// Increase zombie damage every 15 waves
var damageBonus = Math.floor(waveNumber / 15) * 5;
zombie.damage += damageBonus;
zombie.scaleX = 1.0;
zombie.scaleY = 1.0;
zombies.push(zombie);
game.addChild(zombie);
}
function shootBullet(targetX, targetY) {
if (player.shoot()) {
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
var dx = targetX - player.x;
var dy = targetY - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
bullet.dx = dx / distance;
bullet.dy = dy / distance;
// Rotate player to face shooting direction
player.rotation = Math.atan2(dy, dx);
}
bullet.scaleX = 0.15;
bullet.scaleY = 0.15;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
}
game.down = function (x, y, obj) {
// Pause button click detection (top-right corner)
if (!showingGameOver && !showingMarket && !isPaused) {
if (x >= 2048 - 200 && x <= 2048 && y >= 80 && y <= 160) {
showPause();
return;
}
}
// Resume/Market/Restart button clicks when paused
if (isPaused) {
// Resume button click
if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 - 100 && y <= 2732 / 2 - 0) {
hidePause();
return;
}
// Market button click
if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 + 0 && y <= 2732 / 2 + 100) {
hidePause();
showMarket();
return;
}
// Restart button click
if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 + 100 && y <= 2732 / 2 + 200) {
hidePause();
restartGame();
return;
}
return;
}
if (showingGameOver) {
// Market button click detection
if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 + 10 && y <= 2732 / 2 + 90) {
showMarket();
return;
}
// Restart button click detection
if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 + 110 && y <= 2732 / 2 + 190) {
restartGame();
return;
}
} else if (showingMarket) {
var currentCoins = storage.coins;
// Health upgrade button click
if (x >= 2048 / 2 - 300 && x <= 2048 / 2 + 300 && y >= 2732 / 2 - 200 && y <= 2732 / 2 - 100) {
if (storage.coins >= healthUpgradeCost) {
storage.coins -= healthUpgradeCost;
healthUpgradeCost = Math.floor(healthUpgradeCost * 1.5); // Increase cost by 50%
storage.healthUpgradeCost = healthUpgradeCost; // Save to storage
storage.healthUpgrades++;
player.maxHealth += 20;
player.health = Math.min(player.health + 20, player.maxHealth);
coinDisplay.setText('COIN: ' + storage.coins);
LK.getSound('coinPurchase').play();
hideMarket();
showMarket(); // Refresh market display
}
return;
}
// Ammo upgrade button click
if (x >= 2048 / 2 - 250 && x <= 2048 / 2 + 250 && y >= 2732 / 2 - 100 && y <= 2732 / 2 + 0) {
if (storage.coins >= ammoUpgradeCost) {
storage.coins -= ammoUpgradeCost;
ammoUpgradeCost = Math.floor(ammoUpgradeCost * 1.5); // Increase cost by 50%
storage.ammoUpgradeCost = ammoUpgradeCost; // Save to storage
storage.ammoUpgrades++;
player.maxAmmo += 10;
player.ammo = Math.min(player.ammo + 10, player.maxAmmo);
coinDisplay.setText('COIN: ' + storage.coins);
LK.getSound('coinPurchase').play();
hideMarket();
showMarket(); // Refresh market display
}
return;
}
// Speed upgrade button click
if (x >= 2048 / 2 - 275 && x <= 2048 / 2 + 275 && y >= 2732 / 2 + 0 && y <= 2732 / 2 + 100) {
if (storage.coins >= speedUpgradeCost) {
storage.coins -= speedUpgradeCost;
speedUpgradeCost = Math.floor(speedUpgradeCost * 1.5); // Increase cost by 50%
storage.speedUpgradeCost = speedUpgradeCost; // Save to storage
storage.speedUpgrades++;
player.baseShootCooldown = Math.max(1, player.baseShootCooldown - 1);
coinDisplay.setText('COIN: ' + storage.coins);
LK.getSound('coinPurchase').play();
hideMarket();
showMarket(); // Refresh market display
}
return;
}
// Close button click
if (x >= 2048 / 2 - 200 && x <= 2048 / 2 + 200 && y >= 2732 / 2 + 150 && y <= 2732 / 2 + 250) {
hideMarket();
return;
}
} else {
shootBullet(x, y);
}
};
game.update = function () {
if (showingGameOver || showingMarket || isPaused) {
return;
}
spawnTimer++;
if (zombiesSpawned < zombiesInWave && spawnTimer >= 60) {
spawnZombie();
zombiesSpawned++;
spawnTimer = 0;
}
if (zombiesSpawned >= zombiesInWave && zombies.length === 0) {
waveNumber++;
zombiesInWave = Math.min(5 + waveNumber * 2, 20);
zombiesSpawned = 0;
waveDisplay.setText('Wave: ' + waveNumber);
// Increase zombie speed every 10 waves
if (waveNumber % 10 === 0) {
for (var i = 0; i < zombies.length; i++) {
zombies[i].speed += 0.5;
}
}
}
// Check if player has no ammo and end game
if (player.ammo <= 0) {
LK.effects.flashScreen(0xff0000, 1000);
showCustomGameOver();
return;
}
healthBar.setText('Health: ' + player.health);
ammoDisplay.setText('Ammo: ' + player.ammo);
scoreDisplay.setText('SCORE: ' + LK.getScore());
coinDisplay.setText('COIN: ' + storage.coins);
waveInfo.setText('Wave: ' + waveNumber);
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].update();
}
for (var i = zombies.length - 1; i >= 0; i--) {
zombies[i].update();
}
};
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -233,8 +233,10 @@
var gameOverScreen = null;
var showingGameOver = false;
var showingMarket = false;
var marketPanel = null;
+var isPaused = false;
+var pausePanel = null;
// Upgrade costs that increase with each purchase - loaded from storage
var healthUpgradeCost = storage.healthUpgradeCost;
var ammoUpgradeCost = storage.ammoUpgradeCost;
var speedUpgradeCost = storage.speedUpgradeCost;
@@ -309,8 +311,26 @@
fill: 0xFFFF00
});
waveDisplay.anchor.set(1, 0);
LK.gui.topRight.addChild(waveDisplay);
+var pauseButton = LK.getAsset('marketButton', {
+ width: 200,
+ height: 80,
+ anchorX: 1,
+ anchorY: 0,
+ x: 0,
+ y: 80
+});
+pauseButton.tint = 0xFF9800;
+LK.gui.topRight.addChild(pauseButton);
+var pauseText = new Text2('PAUSE', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+pauseText.anchor.set(1, 0);
+pauseText.x = -10;
+pauseText.y = 105;
+LK.gui.topRight.addChild(pauseText);
function showCustomGameOver() {
if (showingGameOver) return;
showingGameOver = true;
gameOverScreen = new Container();
@@ -585,8 +605,95 @@
marketPanel = null;
}
showingMarket = false;
}
+function showPause() {
+ if (isPaused) return;
+ isPaused = true;
+ pausePanel = new Container();
+ // Semi-transparent background
+ var background = LK.getAsset('arena', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2,
+ scaleX: 3,
+ scaleY: 3
+ });
+ background.alpha = 0.8;
+ background.tint = 0x000000;
+ pausePanel.addChild(background);
+ // Pause title
+ var pauseTitle = new Text2('PAUSED', {
+ size: 140,
+ fill: 0xFFFFFF
+ });
+ pauseTitle.anchor.set(0.5, 0.5);
+ pauseTitle.x = 2048 / 2;
+ pauseTitle.y = 2732 / 2 - 200;
+ pausePanel.addChild(pauseTitle);
+ // Resume button
+ var resumeButton = LK.getAsset('marketButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2 - 50
+ });
+ resumeButton.tint = 0x4CAF50;
+ resumeButton.down = function (x, y, obj) {
+ hidePause();
+ };
+ pausePanel.addChild(resumeButton);
+ var resumeText = new Text2('RESUME', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ resumeText.anchor.set(0.5, 0.5);
+ resumeText.x = 2048 / 2;
+ resumeText.y = 2732 / 2 - 50;
+ pausePanel.addChild(resumeText);
+ // Market button
+ var marketButton = LK.getAsset('marketButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2 + 50
+ });
+ pausePanel.addChild(marketButton);
+ var marketText = new Text2('MARKET', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ marketText.anchor.set(0.5, 0.5);
+ marketText.x = 2048 / 2;
+ marketText.y = 2732 / 2 + 50;
+ pausePanel.addChild(marketText);
+ // Restart button
+ var restartButton = LK.getAsset('marketButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2 + 150
+ });
+ restartButton.tint = 0x2196F3;
+ pausePanel.addChild(restartButton);
+ var restartText = new Text2('RESTART', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ restartText.anchor.set(0.5, 0.5);
+ restartText.x = 2048 / 2;
+ restartText.y = 2732 / 2 + 150;
+ pausePanel.addChild(restartText);
+ game.addChild(pausePanel);
+}
+function hidePause() {
+ if (pausePanel) {
+ pausePanel.destroy();
+ pausePanel = null;
+ }
+ isPaused = false;
+}
function restartGame() {
hideGameOver();
// Reset player with upgraded stats
player.maxHealth = 100 + storage.healthUpgrades * 20;
@@ -694,8 +801,36 @@
LK.getSound('shoot').play();
}
}
game.down = function (x, y, obj) {
+ // Pause button click detection (top-right corner)
+ if (!showingGameOver && !showingMarket && !isPaused) {
+ if (x >= 2048 - 200 && x <= 2048 && y >= 80 && y <= 160) {
+ showPause();
+ return;
+ }
+ }
+ // Resume/Market/Restart button clicks when paused
+ if (isPaused) {
+ // Resume button click
+ if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 - 100 && y <= 2732 / 2 - 0) {
+ hidePause();
+ return;
+ }
+ // Market button click
+ if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 + 0 && y <= 2732 / 2 + 100) {
+ hidePause();
+ showMarket();
+ return;
+ }
+ // Restart button click
+ if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 + 100 && y <= 2732 / 2 + 200) {
+ hidePause();
+ restartGame();
+ return;
+ }
+ return;
+ }
if (showingGameOver) {
// Market button click detection
if (x >= 2048 / 2 - 150 && x <= 2048 / 2 + 150 && y >= 2732 / 2 + 10 && y <= 2732 / 2 + 90) {
showMarket();
@@ -764,9 +899,9 @@
shootBullet(x, y);
}
};
game.update = function () {
- if (showingGameOver || showingMarket) {
+ if (showingGameOver || showingMarket || isPaused) {
return;
}
spawnTimer++;
if (zombiesSpawned < zombiesInWave && spawnTimer >= 60) {
Üstten görünümlü zombi. In-Game asset. 2d. High contrast. No shadows
Ortasında elips şeklinde bir boşluk hariç her yeri sık ağaçlık olan bir orman. In-Game asset. 2d. High contrast. No shadows
Ahşap tema. In-Game asset. 2d. High contrast. No shadows
pompalı tüfek mermisi. In-Game asset. 2d. High contrast. No shadows
hafif makineli tüfek mermisi. In-Game asset. 2d. High contrast. No shadows
Uzi çiz. In-Game asset. 2d. High contrast. No shadows
Pompalı Tüfek. In-Game asset. 2d. High contrast. No shadows
Bunun arkaplanını sil
Arkaplanını sil
boss zombie. In-Game asset. 2d. High contrast. No shadows
dümdüz sadece buzullardan oluşsun aralarında yarıklar olmasın