User prompt
Öldürülen her düşman için puan verilsin. Oyun bitince o puanlarla karakterin geliştirilebileceği bir panel açılsın ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Zombie Blaster Arena
Initial prompt
Zombotron tarzı bir oyun yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AmmoPickup = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('ammoPickup', {
anchorX: 0.5,
anchorY: 0.5
});
self.ammoAmount = 10;
self.lifetime = 600;
self.lastPlayerCollision = false;
self.update = function () {
self.lifetime--;
graphics.rotation += 0.05;
if (self.lifetime <= 0) {
self.remove();
return;
}
var currentCollision = self.intersects(player);
if (!self.lastPlayerCollision && currentCollision) {
player.addAmmo(self.ammoAmount);
LK.getSound('pickup').play();
self.remove();
return;
}
self.lastPlayerCollision = currentCollision;
};
self.remove = function () {
var index = ammoPickups.indexOf(self);
if (index > -1) {
ammoPickups.splice(index, 1);
}
self.destroy();
};
return self;
});
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;
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.update = function () {
if (self.shootCooldown > 0) {
self.shootCooldown--;
}
};
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, 200);
}
};
self.addAmmo = function (amount) {
self.ammo = Math.min(self.ammo + amount, self.maxAmmo);
};
self.canShoot = function () {
return self.ammo > 0 && self.shootCooldown <= 0;
};
self.shoot = function () {
if (self.canShoot()) {
self.ammo--;
self.shootCooldown = 10;
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);
self.takeDamage(1);
}
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);
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
});
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
var zombies = [];
var bullets = [];
var ammoPickups = [];
var waveNumber = 1;
var zombiesInWave = 5;
var zombiesSpawned = 0;
var spawnTimer = 0;
var pickupTimer = 0;
var healthBar = new Text2('Health: 100', {
size: 60,
fill: 0xFF0000
});
healthBar.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthBar);
var ammoDisplay = new Text2('Ammo: 30', {
size: 60,
fill: 0x00FF00
});
ammoDisplay.anchor.set(0, 0);
ammoDisplay.y = 70;
LK.gui.topLeft.addChild(ammoDisplay);
var scoreDisplay = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreDisplay);
var waveDisplay = new Text2('Wave: 1', {
size: 60,
fill: 0xFFFF00
});
waveDisplay.anchor.set(1, 0);
LK.gui.topRight.addChild(waveDisplay);
function spawnZombie() {
var zombie = new Zombie();
var angle = Math.random() * Math.PI * 2;
var spawnRadius = 1000;
zombie.x = player.x + Math.cos(angle) * spawnRadius;
zombie.y = player.y + Math.sin(angle) * spawnRadius;
zombies.push(zombie);
game.addChild(zombie);
}
function spawnAmmoPickup() {
var pickup = new AmmoPickup();
var angle = Math.random() * Math.PI * 2;
var radius = 200 + Math.random() * 400;
pickup.x = player.x + Math.cos(angle) * radius;
pickup.y = player.y + Math.sin(angle) * radius;
ammoPickups.push(pickup);
game.addChild(pickup);
}
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;
}
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
}
game.down = function (x, y, obj) {
shootBullet(x, y);
};
game.update = function () {
spawnTimer++;
pickupTimer++;
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);
for (var i = 0; i < zombies.length; i++) {
zombies[i].speed += 0.1;
}
}
if (pickupTimer >= 900) {
spawnAmmoPickup();
pickupTimer = 0;
}
healthBar.setText('Health: ' + player.health);
ammoDisplay.setText('Ammo: ' + player.ammo);
scoreDisplay.setText('Score: ' + LK.getScore());
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].update();
}
for (var i = zombies.length - 1; i >= 0; i--) {
zombies[i].update();
}
for (var i = ammoPickups.length - 1; i >= 0; i--) {
ammoPickups[i].update();
}
};
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,289 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var AmmoPickup = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('ammoPickup', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.ammoAmount = 10;
+ self.lifetime = 600;
+ self.lastPlayerCollision = false;
+ self.update = function () {
+ self.lifetime--;
+ graphics.rotation += 0.05;
+ if (self.lifetime <= 0) {
+ self.remove();
+ return;
+ }
+ var currentCollision = self.intersects(player);
+ if (!self.lastPlayerCollision && currentCollision) {
+ player.addAmmo(self.ammoAmount);
+ LK.getSound('pickup').play();
+ self.remove();
+ return;
+ }
+ self.lastPlayerCollision = currentCollision;
+ };
+ self.remove = function () {
+ var index = ammoPickups.indexOf(self);
+ if (index > -1) {
+ ammoPickups.splice(index, 1);
+ }
+ self.destroy();
+ };
+ return self;
+});
+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;
+ 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.update = function () {
+ if (self.shootCooldown > 0) {
+ self.shootCooldown--;
+ }
+ };
+ 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, 200);
+ }
+ };
+ self.addAmmo = function (amount) {
+ self.ammo = Math.min(self.ammo + amount, self.maxAmmo);
+ };
+ self.canShoot = function () {
+ return self.ammo > 0 && self.shootCooldown <= 0;
+ };
+ self.shoot = function () {
+ if (self.canShoot()) {
+ self.ammo--;
+ self.shootCooldown = 10;
+ 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);
+ self.takeDamage(1);
+ }
+ 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);
+ 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: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2d2d2d
+});
+
+/****
+* Game Code
+****/
+var arena = game.attachAsset('arena', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+});
+var player = game.addChild(new Player());
+player.x = 2048 / 2;
+player.y = 2732 / 2;
+var zombies = [];
+var bullets = [];
+var ammoPickups = [];
+var waveNumber = 1;
+var zombiesInWave = 5;
+var zombiesSpawned = 0;
+var spawnTimer = 0;
+var pickupTimer = 0;
+var healthBar = new Text2('Health: 100', {
+ size: 60,
+ fill: 0xFF0000
+});
+healthBar.anchor.set(0, 0);
+LK.gui.topLeft.addChild(healthBar);
+var ammoDisplay = new Text2('Ammo: 30', {
+ size: 60,
+ fill: 0x00FF00
+});
+ammoDisplay.anchor.set(0, 0);
+ammoDisplay.y = 70;
+LK.gui.topLeft.addChild(ammoDisplay);
+var scoreDisplay = new Text2('Score: 0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreDisplay.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreDisplay);
+var waveDisplay = new Text2('Wave: 1', {
+ size: 60,
+ fill: 0xFFFF00
+});
+waveDisplay.anchor.set(1, 0);
+LK.gui.topRight.addChild(waveDisplay);
+function spawnZombie() {
+ var zombie = new Zombie();
+ var angle = Math.random() * Math.PI * 2;
+ var spawnRadius = 1000;
+ zombie.x = player.x + Math.cos(angle) * spawnRadius;
+ zombie.y = player.y + Math.sin(angle) * spawnRadius;
+ zombies.push(zombie);
+ game.addChild(zombie);
+}
+function spawnAmmoPickup() {
+ var pickup = new AmmoPickup();
+ var angle = Math.random() * Math.PI * 2;
+ var radius = 200 + Math.random() * 400;
+ pickup.x = player.x + Math.cos(angle) * radius;
+ pickup.y = player.y + Math.sin(angle) * radius;
+ ammoPickups.push(pickup);
+ game.addChild(pickup);
+}
+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;
+ }
+ bullets.push(bullet);
+ game.addChild(bullet);
+ LK.getSound('shoot').play();
+ }
+}
+game.down = function (x, y, obj) {
+ shootBullet(x, y);
+};
+game.update = function () {
+ spawnTimer++;
+ pickupTimer++;
+ 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);
+ for (var i = 0; i < zombies.length; i++) {
+ zombies[i].speed += 0.1;
+ }
+ }
+ if (pickupTimer >= 900) {
+ spawnAmmoPickup();
+ pickupTimer = 0;
+ }
+ healthBar.setText('Health: ' + player.health);
+ ammoDisplay.setText('Ammo: ' + player.ammo);
+ scoreDisplay.setText('Score: ' + LK.getScore());
+ for (var i = bullets.length - 1; i >= 0; i--) {
+ bullets[i].update();
+ }
+ for (var i = zombies.length - 1; i >= 0; i--) {
+ zombies[i].update();
+ }
+ for (var i = ammoPickups.length - 1; i >= 0; i--) {
+ ammoPickups[i].update();
+ }
+};
+LK.playMusic('bgmusic');
\ No newline at end of file
Ü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