User prompt
silah sıkınca ses te olsun
User prompt
silah mavi bir renk olsun bide yeni nesneye yap
User prompt
sen yapsan
User prompt
oyuncunu elinde silah olsun
User prompt
hareket edelim
Code edit (1 edits merged)
Please save this source code
User prompt
Zombie Escape: Shoot & Survive
Initial prompt
silahlar olsun bide zombiler olsun biz onlardan kaçıp vuralım
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGfx = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = bulletGfx.width / 2;
self.speed = 32; // Fast bullet
self.vx = 0;
self.vy = 0;
// Set direction
self.setDirection = function (dx, dy) {
var len = Math.sqrt(dx * dx + dy * dy);
if (len > 0) {
self.vx = dx / len * self.speed;
self.vy = dy / len * self.speed;
}
};
self.update = function () {
self.x += self.vx;
self.y += self.vy;
};
return self;
});
// Hero class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGfx = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
// Add a gun to hero's hand
// Use the new blue gun asset, positioned to the right hand
var gunGfx = self.attachAsset('bluegun', {
anchorX: 0.2,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 0.6,
x: heroGfx.width * 0.38,
// offset to right hand
y: 0
});
// Track gun rotation
self.gunGfx = gunGfx;
self.gunAngle = 0;
// For future upgrades: health, weapon, etc.
self.radius = heroGfx.width / 2;
return self;
});
// Zombie class
var Zombie = Container.expand(function () {
var self = Container.call(this);
var zombieGfx = self.attachAsset('zombie', {
anchorX: 0.5,
anchorY: 0.5
});
self.radius = zombieGfx.width / 2;
// Speed will be set on spawn
self.speed = 2 + Math.random() * 1.5; // Slight randomization
// Direction vector
self.vx = 0;
self.vy = 0;
// Set direction towards hero
self.setDirection = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var len = Math.sqrt(dx * dx + dy * dy);
if (len > 0) {
self.vx = dx / len * self.speed;
self.vy = dy / len * self.speed;
}
};
// Move towards direction
self.update = function () {
self.x += self.vx;
self.y += self.vy;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x181818
});
/****
* Game Code
****/
// New blue gun asset
// Game area
// Hero asset: red box
// Zombie asset: green ellipse
// Bullet asset: yellow box
// Sound for shooting
var GAME_W = 2048;
var GAME_H = 2732;
// Hero setup
var hero = new Hero();
hero.x = GAME_W / 2;
hero.y = GAME_H / 2;
game.addChild(hero);
// Bullets and zombies arrays
var bullets = [];
var zombies = [];
// Score
var score = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Dragging
var dragNode = null;
// Touch/move controls
function handleMove(x, y, obj) {
// Drag hero
if (dragNode === hero) {
// Clamp hero inside game area, avoid top left 100x100
var minX = hero.radius + 100;
var maxX = GAME_W - hero.radius;
var minY = hero.radius;
var maxY = GAME_H - hero.radius;
hero.x = Math.max(minX, Math.min(maxX, x));
hero.y = Math.max(minY, Math.min(maxY, y));
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Only drag if touch is on hero
var dx = x - hero.x;
var dy = y - hero.y;
if (dx * dx + dy * dy <= hero.radius * hero.radius) {
dragNode = hero;
handleMove(x, y, obj);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Shooting: tap anywhere not on hero to shoot
game.tap = function (x, y, obj) {
// Don't shoot if tap is on hero
var dx = x - hero.x;
var dy = y - hero.y;
if (dx * dx + dy * dy <= hero.radius * hero.radius) return;
// Create bullet
var bullet = new Bullet();
bullet.x = hero.x;
bullet.y = hero.y;
bullet.setDirection(dx, dy);
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
// Rotate gun towards shot direction
if (typeof hero.gunGfx !== "undefined") {
hero.gunGfx.rotation = Math.atan2(dy, dx);
}
};
game.down = function (x, y, obj) {
// Drag or shoot
var dx = x - hero.x;
var dy = y - hero.y;
if (dx * dx + dy * dy <= hero.radius * hero.radius) {
dragNode = hero;
handleMove(x, y, obj);
} else {
// Shoot
var bullet = new Bullet();
bullet.x = hero.x;
bullet.y = hero.y;
bullet.setDirection(dx, dy);
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
// Rotate gun towards shot direction
if (typeof hero.gunGfx !== "undefined") {
hero.gunGfx.rotation = Math.atan2(dy, dx);
}
}
};
// Zombie spawn timer
var zombieSpawnInterval = 90; // frames
var zombieSpawnTimer = 0;
// Helper: spawn zombie at random edge
function spawnZombie() {
var zombie = new Zombie();
// Random edge: 0=top,1=bottom,2=left,3=right
var edge = Math.floor(Math.random() * 4);
var margin = 80;
if (edge === 0) {
// top
zombie.x = margin + Math.random() * (GAME_W - 2 * margin);
zombie.y = -zombie.radius;
} else if (edge === 1) {
// bottom
zombie.x = margin + Math.random() * (GAME_W - 2 * margin);
zombie.y = GAME_H + zombie.radius;
} else if (edge === 2) {
// left
zombie.x = -zombie.radius;
zombie.y = margin + Math.random() * (GAME_H - 2 * margin);
} else {
// right
zombie.x = GAME_W + zombie.radius;
zombie.y = margin + Math.random() * (GAME_H - 2 * margin);
}
zombie.setDirection(hero.x, hero.y);
zombies.push(zombie);
game.addChild(zombie);
}
// Main update loop
game.update = function () {
// Update zombies
for (var i = zombies.length - 1; i >= 0; i--) {
var z = zombies[i];
// Always update direction towards hero
z.setDirection(hero.x, hero.y);
z.update();
// Check collision with hero
var dx = z.x - hero.x;
var dy = z.y - hero.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < z.radius + hero.radius - 10) {
// Game over
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
// Update bullets
for (var j = bullets.length - 1; j >= 0; j--) {
var b = bullets[j];
b.update();
// Remove if out of bounds
if (b.x < -b.radius || b.x > GAME_W + b.radius || b.y < -b.radius || b.y > GAME_H + b.radius) {
b.destroy();
bullets.splice(j, 1);
continue;
}
// Check collision with zombies
for (var k = zombies.length - 1; k >= 0; k--) {
var z2 = zombies[k];
var dx2 = b.x - z2.x;
var dy2 = b.y - z2.y;
var dist2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
if (dist2 < b.radius + z2.radius - 10) {
// Zombie killed
z2.destroy();
zombies.splice(k, 1);
b.destroy();
bullets.splice(j, 1);
// Score up
score += 1;
scoreTxt.setText(score);
break;
}
}
}
// Spawn zombies
zombieSpawnTimer++;
if (zombieSpawnTimer >= zombieSpawnInterval) {
spawnZombie();
zombieSpawnTimer = 0;
// Gradually increase spawn rate
if (zombieSpawnInterval > 30) zombieSpawnInterval -= 1;
}
};
// Center hero on start
hero.x = GAME_W / 2;
hero.y = GAME_H / 2;
// Initial zombie spawn
for (var i = 0; i < 3; i++) {
spawnZombie();
} ===================================================================
--- original.js
+++ change.js
mermi. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
oyuncu,karekter. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
silah. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
zombi. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat