User prompt
hasar yediğimiz zaman ekrandaki kırmızı rengi kaldır hasar efekti olmasın
User prompt
erzakları topladığımız zaman canımız %25 artsın
User prompt
karakter zombilere yaklaştığı zaman katana otomatik vursun
User prompt
Katananın vuruş alani %20 artsın
User prompt
karakterin 100 canı olsun
User prompt
katana zombilere hasar versin ve karakterin 10 canı olsun
User prompt
zombiler evlerin etrafında dursun biz zombilere yaklaştığımız zaman onlar bizim üzerimize koşsun
Code edit (1 edits merged)
Please save this source code
User prompt
Katana Survivor: Zombi Kıyameti
Initial prompt
dünyada tek başına kalmış savaşçı bir kadınız elimizde çok keskin bir katana var ve düşmanlarımız zombiler. amacımız evlere girip evlerden erzak toplayıp zombileri öldürüp hayatta kalmak.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // House class var House = Container.expand(function () { var self = Container.call(this); var houseSprite = self.attachAsset('house', { anchorX: 0.5, anchorY: 0.5 }); // Loot inside self.hasLoot = true; self.loot = null; // Place loot inside house self.spawnLoot = function () { if (!self.hasLoot) return; var loot = LK.getAsset('loot', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); self.addChild(loot); self.loot = loot; }; // Remove loot self.takeLoot = function () { if (self.loot) { self.loot.destroy(); self.loot = null; self.hasLoot = false; } }; return self; }); // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerSprite = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); // Katana asset (rotates for slash) var katana = self.attachAsset('katana', { anchorX: 0.1, anchorY: 0.5, x: 60, // right hand y: 0 }); self.katana = katana; katana.rotation = 0; // Katana slash cooldown self.canSlash = true; // Katana slash animation self.slash = function (dir) { if (!self.canSlash) return; self.canSlash = false; // Animate katana swing var startRot = dir === 'left' ? -Math.PI / 3 : Math.PI / 3; katana.rotation = 0; tween(katana, { rotation: startRot }, { duration: 60, easing: tween.cubicOut, onFinish: function onFinish() { tween(katana, { rotation: 0 }, { duration: 120, easing: tween.cubicIn, onFinish: function onFinish() { self.canSlash = true; } }); } }); // Slash effect var slashFx = LK.getAsset('slash', { anchorX: 0.1, anchorY: 0.5, x: katana.x, y: katana.y, rotation: startRot, alpha: 0.7 }); self.addChild(slashFx); tween(slashFx, { alpha: 0 }, { duration: 180, onFinish: function onFinish() { slashFx.destroy(); } }); }; // Move to (x, y) with bounds self.moveTo = function (x, y) { // Clamp to game area (leave 100px margin) var hw = self.width / 2, hh = self.height / 2; var minX = 100 + hw, maxX = 2048 - hw - 100; var minY = 100 + hh, maxY = 2732 - hh - 100; self.x = Math.max(minX, Math.min(maxX, x)); self.y = Math.max(minY, Math.min(maxY, y)); }; return self; }); // Zombie class var Zombie = Container.expand(function () { var self = Container.call(this); var zombieSprite = self.attachAsset('zombie', { anchorX: 0.5, anchorY: 0.5 }); // Target to follow (player) self.target = null; self.speed = 2.2 + Math.random() * 1.2; // randomize speed a bit // For hit flash self.isHit = false; // For AI: wander around house if not chasing self.homeX = 0; self.homeY = 0; self.update = function () { if (!self.target) return; // Move towards player var dx = self.target.x - self.x; var dy = self.target.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 10) { self.x += dx / dist * self.speed; self.y += dy / dist * self.speed; } }; // Flash red when hit self.flashHit = function () { if (self.isHit) return; self.isHit = true; tween(zombieSprite, { tint: 0xff0000 }, { duration: 80, onFinish: function onFinish() { tween(zombieSprite, { tint: 0x4e9a06 }, { duration: 120, onFinish: function onFinish() { self.isHit = false; } }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x23272e }); /**** * Game Code ****/ // Katana sallama efekti // Zombi öldürme efekti // Erzak (loot) // Ev // Zombi // Katana (kılıç) // Kadın savaşçı (player) // --- Game variables --- var player; var zombies = []; var houses = []; var score = 0; var scoreTxt; var dragNode = null; var lastPlayerX = 0, lastPlayerY = 0; var lastIntersectingZombie = false; var lastIntersectingLoot = false; var gameOver = false; // --- UI --- scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // --- Spawn houses --- function spawnHouses() { houses = []; var housePositions = [{ x: 400, y: 700 }, { x: 1648, y: 700 }, { x: 400, y: 2000 }, { x: 1648, y: 2000 }, { x: 1024, y: 1400 }]; for (var i = 0; i < housePositions.length; i++) { var h = new House(); h.x = housePositions[i].x; h.y = housePositions[i].y; h.spawnLoot(); houses.push(h); game.addChild(h); } } // --- Spawn zombies around houses --- function spawnZombies() { zombies = []; for (var i = 0; i < houses.length; i++) { // 2 zombies per house for (var j = 0; j < 2; j++) { var z = new Zombie(); // Place randomly around house var angle = Math.random() * Math.PI * 2; var dist = 180 + Math.random() * 60; z.x = houses[i].x + Math.cos(angle) * dist; z.y = houses[i].y + Math.sin(angle) * dist; z.homeX = z.x; z.homeY = z.y; z.target = null; // will be set to player later zombies.push(z); game.addChild(z); } } } // --- Spawn player --- function spawnPlayer() { player = new Player(); player.x = 1024; player.y = 2400; game.addChild(player); } // --- Reset game state --- function resetGame() { // Remove all children except GUI for (var i = game.children.length - 1; i >= 0; i--) { game.children[i].destroy(); } score = 0; scoreTxt.setText(score); gameOver = false; spawnHouses(); spawnZombies(); spawnPlayer(); // Set all zombies to follow player for (var i = 0; i < zombies.length; i++) { zombies[i].target = player; } } resetGame(); // --- Dragging player --- game.down = function (x, y, obj) { // Only allow drag if not game over if (gameOver) return; // Only drag if touch is on player var local = player.toLocal(game.toGlobal({ x: x, y: y })); if (local.x > -player.width / 2 && local.x < player.width / 2 && local.y > -player.height / 2 && local.y < player.height / 2) { dragNode = player; } }; game.up = function (x, y, obj) { dragNode = null; }; function handleMove(x, y, obj) { if (gameOver) return; if (dragNode) { player.moveTo(x, y); } } game.move = handleMove; // --- Katana slash on tap (anywhere) --- game.tap = function (x, y, obj) { if (gameOver) return; // Determine direction: tap left or right of player var dir = x < player.x ? 'left' : 'right'; player.slash(dir); }; // Since LK does not have tap, simulate with down+up var tapTimeout = null; game.down = function (x, y, obj) { if (gameOver) return; // If touch is on player, drag var local = player.toLocal(game.toGlobal({ x: x, y: y })); if (local.x > -player.width / 2 && local.x < player.width / 2 && local.y > -player.height / 2 && local.y < player.height / 2) { dragNode = player; } else { // Else, treat as katana slash var dir = x < player.x ? 'left' : 'right'; player.slash(dir); } // For tap simulation if (tapTimeout) LK.clearTimeout(tapTimeout); tapTimeout = LK.setTimeout(function () { tapTimeout = null; }, 200); }; game.up = function (x, y, obj) { dragNode = null; }; // --- Main update loop --- game.update = function () { if (gameOver) return; // --- Zombies update --- for (var i = zombies.length - 1; i >= 0; i--) { var z = zombies[i]; z.update(); // Check collision with player (game over) if (z.intersects(player)) { // Flash screen red LK.effects.flashScreen(0xff0000, 1000); gameOver = true; LK.showGameOver(); return; } } // --- Katana hit detection --- // If katana is swinging, check for zombie hits for (var i = zombies.length - 1; i >= 0; i--) { var z = zombies[i]; // Katana tip position var katana = player.katana; var katanaTipX = player.x + Math.cos(katana.rotation) * katana.x; var katanaTipY = player.y + Math.sin(katana.rotation) * katana.x; // Create a small rectangle at katana tip var katanaRect = { x: katanaTipX - 30, y: katanaTipY - 30, width: 60, height: 60 }; // Zombie rectangle var zRect = { x: z.x - z.width / 2, y: z.y - z.height / 2, width: z.width, height: z.height }; // Simple AABB collision var hit = !(katanaRect.x + katanaRect.width < zRect.x || katanaRect.x > zRect.x + zRect.width || katanaRect.y + katanaRect.height < zRect.y || katanaRect.y > zRect.y + zRect.height); if (hit && player.katana.rotation !== 0) { // Kill zombie z.flashHit(); // Blood effect var blood = LK.getAsset('zombieBlood', { anchorX: 0.5, anchorY: 0.5, x: z.x, y: z.y, alpha: 0.8 }); game.addChild(blood); tween(blood, { alpha: 0 }, { duration: 400, onFinish: function onFinish() { blood.destroy(); } }); z.destroy(); zombies.splice(i, 1); // Score score += 10; scoreTxt.setText(score); // Win if all zombies dead and all loot collected if (zombies.length === 0 && allLootCollected()) { LK.showYouWin(); gameOver = true; return; } } } // --- Loot collection --- for (var i = 0; i < houses.length; i++) { var h = houses[i]; if (h.hasLoot && h.loot && player.intersects(h.loot)) { h.takeLoot(); // Score score += 20; scoreTxt.setText(score); // Win if all loot collected and all zombies dead if (zombies.length === 0 && allLootCollected()) { LK.showYouWin(); gameOver = true; return; } } } }; // --- Helper: all loot collected? --- function allLootCollected() { for (var i = 0; i < houses.length; i++) { if (houses[i].hasLoot) return false; } return true; }
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,426 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// House class
+var House = Container.expand(function () {
+ var self = Container.call(this);
+ var houseSprite = self.attachAsset('house', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Loot inside
+ self.hasLoot = true;
+ self.loot = null;
+ // Place loot inside house
+ self.spawnLoot = function () {
+ if (!self.hasLoot) return;
+ var loot = LK.getAsset('loot', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 0
+ });
+ self.addChild(loot);
+ self.loot = loot;
+ };
+ // Remove loot
+ self.takeLoot = function () {
+ if (self.loot) {
+ self.loot.destroy();
+ self.loot = null;
+ self.hasLoot = false;
+ }
+ };
+ return self;
+});
+// Player class
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerSprite = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Katana asset (rotates for slash)
+ var katana = self.attachAsset('katana', {
+ anchorX: 0.1,
+ anchorY: 0.5,
+ x: 60,
+ // right hand
+ y: 0
+ });
+ self.katana = katana;
+ katana.rotation = 0;
+ // Katana slash cooldown
+ self.canSlash = true;
+ // Katana slash animation
+ self.slash = function (dir) {
+ if (!self.canSlash) return;
+ self.canSlash = false;
+ // Animate katana swing
+ var startRot = dir === 'left' ? -Math.PI / 3 : Math.PI / 3;
+ katana.rotation = 0;
+ tween(katana, {
+ rotation: startRot
+ }, {
+ duration: 60,
+ easing: tween.cubicOut,
+ onFinish: function onFinish() {
+ tween(katana, {
+ rotation: 0
+ }, {
+ duration: 120,
+ easing: tween.cubicIn,
+ onFinish: function onFinish() {
+ self.canSlash = true;
+ }
+ });
+ }
+ });
+ // Slash effect
+ var slashFx = LK.getAsset('slash', {
+ anchorX: 0.1,
+ anchorY: 0.5,
+ x: katana.x,
+ y: katana.y,
+ rotation: startRot,
+ alpha: 0.7
+ });
+ self.addChild(slashFx);
+ tween(slashFx, {
+ alpha: 0
+ }, {
+ duration: 180,
+ onFinish: function onFinish() {
+ slashFx.destroy();
+ }
+ });
+ };
+ // Move to (x, y) with bounds
+ self.moveTo = function (x, y) {
+ // Clamp to game area (leave 100px margin)
+ var hw = self.width / 2,
+ hh = self.height / 2;
+ var minX = 100 + hw,
+ maxX = 2048 - hw - 100;
+ var minY = 100 + hh,
+ maxY = 2732 - hh - 100;
+ self.x = Math.max(minX, Math.min(maxX, x));
+ self.y = Math.max(minY, Math.min(maxY, y));
+ };
+ return self;
+});
+// Zombie class
+var Zombie = Container.expand(function () {
+ var self = Container.call(this);
+ var zombieSprite = self.attachAsset('zombie', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Target to follow (player)
+ self.target = null;
+ self.speed = 2.2 + Math.random() * 1.2; // randomize speed a bit
+ // For hit flash
+ self.isHit = false;
+ // For AI: wander around house if not chasing
+ self.homeX = 0;
+ self.homeY = 0;
+ self.update = function () {
+ if (!self.target) return;
+ // Move towards player
+ var dx = self.target.x - self.x;
+ var dy = self.target.y - self.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist > 10) {
+ self.x += dx / dist * self.speed;
+ self.y += dy / dist * self.speed;
+ }
+ };
+ // Flash red when hit
+ self.flashHit = function () {
+ if (self.isHit) return;
+ self.isHit = true;
+ tween(zombieSprite, {
+ tint: 0xff0000
+ }, {
+ duration: 80,
+ onFinish: function onFinish() {
+ tween(zombieSprite, {
+ tint: 0x4e9a06
+ }, {
+ duration: 120,
+ onFinish: function onFinish() {
+ self.isHit = false;
+ }
+ });
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x23272e
+});
+
+/****
+* Game Code
+****/
+// Katana sallama efekti
+// Zombi öldürme efekti
+// Erzak (loot)
+// Ev
+// Zombi
+// Katana (kılıç)
+// Kadın savaşçı (player)
+// --- Game variables ---
+var player;
+var zombies = [];
+var houses = [];
+var score = 0;
+var scoreTxt;
+var dragNode = null;
+var lastPlayerX = 0,
+ lastPlayerY = 0;
+var lastIntersectingZombie = false;
+var lastIntersectingLoot = false;
+var gameOver = false;
+// --- UI ---
+scoreTxt = new Text2('0', {
+ size: 120,
+ fill: "#fff"
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// --- Spawn houses ---
+function spawnHouses() {
+ houses = [];
+ var housePositions = [{
+ x: 400,
+ y: 700
+ }, {
+ x: 1648,
+ y: 700
+ }, {
+ x: 400,
+ y: 2000
+ }, {
+ x: 1648,
+ y: 2000
+ }, {
+ x: 1024,
+ y: 1400
+ }];
+ for (var i = 0; i < housePositions.length; i++) {
+ var h = new House();
+ h.x = housePositions[i].x;
+ h.y = housePositions[i].y;
+ h.spawnLoot();
+ houses.push(h);
+ game.addChild(h);
+ }
+}
+// --- Spawn zombies around houses ---
+function spawnZombies() {
+ zombies = [];
+ for (var i = 0; i < houses.length; i++) {
+ // 2 zombies per house
+ for (var j = 0; j < 2; j++) {
+ var z = new Zombie();
+ // Place randomly around house
+ var angle = Math.random() * Math.PI * 2;
+ var dist = 180 + Math.random() * 60;
+ z.x = houses[i].x + Math.cos(angle) * dist;
+ z.y = houses[i].y + Math.sin(angle) * dist;
+ z.homeX = z.x;
+ z.homeY = z.y;
+ z.target = null; // will be set to player later
+ zombies.push(z);
+ game.addChild(z);
+ }
+ }
+}
+// --- Spawn player ---
+function spawnPlayer() {
+ player = new Player();
+ player.x = 1024;
+ player.y = 2400;
+ game.addChild(player);
+}
+// --- Reset game state ---
+function resetGame() {
+ // Remove all children except GUI
+ for (var i = game.children.length - 1; i >= 0; i--) {
+ game.children[i].destroy();
+ }
+ score = 0;
+ scoreTxt.setText(score);
+ gameOver = false;
+ spawnHouses();
+ spawnZombies();
+ spawnPlayer();
+ // Set all zombies to follow player
+ for (var i = 0; i < zombies.length; i++) {
+ zombies[i].target = player;
+ }
+}
+resetGame();
+// --- Dragging player ---
+game.down = function (x, y, obj) {
+ // Only allow drag if not game over
+ if (gameOver) return;
+ // Only drag if touch is on player
+ var local = player.toLocal(game.toGlobal({
+ x: x,
+ y: y
+ }));
+ if (local.x > -player.width / 2 && local.x < player.width / 2 && local.y > -player.height / 2 && local.y < player.height / 2) {
+ dragNode = player;
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+function handleMove(x, y, obj) {
+ if (gameOver) return;
+ if (dragNode) {
+ player.moveTo(x, y);
+ }
+}
+game.move = handleMove;
+// --- Katana slash on tap (anywhere) ---
+game.tap = function (x, y, obj) {
+ if (gameOver) return;
+ // Determine direction: tap left or right of player
+ var dir = x < player.x ? 'left' : 'right';
+ player.slash(dir);
+};
+// Since LK does not have tap, simulate with down+up
+var tapTimeout = null;
+game.down = function (x, y, obj) {
+ if (gameOver) return;
+ // If touch is on player, drag
+ var local = player.toLocal(game.toGlobal({
+ x: x,
+ y: y
+ }));
+ if (local.x > -player.width / 2 && local.x < player.width / 2 && local.y > -player.height / 2 && local.y < player.height / 2) {
+ dragNode = player;
+ } else {
+ // Else, treat as katana slash
+ var dir = x < player.x ? 'left' : 'right';
+ player.slash(dir);
+ }
+ // For tap simulation
+ if (tapTimeout) LK.clearTimeout(tapTimeout);
+ tapTimeout = LK.setTimeout(function () {
+ tapTimeout = null;
+ }, 200);
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// --- Main update loop ---
+game.update = function () {
+ if (gameOver) return;
+ // --- Zombies update ---
+ for (var i = zombies.length - 1; i >= 0; i--) {
+ var z = zombies[i];
+ z.update();
+ // Check collision with player (game over)
+ if (z.intersects(player)) {
+ // Flash screen red
+ LK.effects.flashScreen(0xff0000, 1000);
+ gameOver = true;
+ LK.showGameOver();
+ return;
+ }
+ }
+ // --- Katana hit detection ---
+ // If katana is swinging, check for zombie hits
+ for (var i = zombies.length - 1; i >= 0; i--) {
+ var z = zombies[i];
+ // Katana tip position
+ var katana = player.katana;
+ var katanaTipX = player.x + Math.cos(katana.rotation) * katana.x;
+ var katanaTipY = player.y + Math.sin(katana.rotation) * katana.x;
+ // Create a small rectangle at katana tip
+ var katanaRect = {
+ x: katanaTipX - 30,
+ y: katanaTipY - 30,
+ width: 60,
+ height: 60
+ };
+ // Zombie rectangle
+ var zRect = {
+ x: z.x - z.width / 2,
+ y: z.y - z.height / 2,
+ width: z.width,
+ height: z.height
+ };
+ // Simple AABB collision
+ var hit = !(katanaRect.x + katanaRect.width < zRect.x || katanaRect.x > zRect.x + zRect.width || katanaRect.y + katanaRect.height < zRect.y || katanaRect.y > zRect.y + zRect.height);
+ if (hit && player.katana.rotation !== 0) {
+ // Kill zombie
+ z.flashHit();
+ // Blood effect
+ var blood = LK.getAsset('zombieBlood', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: z.x,
+ y: z.y,
+ alpha: 0.8
+ });
+ game.addChild(blood);
+ tween(blood, {
+ alpha: 0
+ }, {
+ duration: 400,
+ onFinish: function onFinish() {
+ blood.destroy();
+ }
+ });
+ z.destroy();
+ zombies.splice(i, 1);
+ // Score
+ score += 10;
+ scoreTxt.setText(score);
+ // Win if all zombies dead and all loot collected
+ if (zombies.length === 0 && allLootCollected()) {
+ LK.showYouWin();
+ gameOver = true;
+ return;
+ }
+ }
+ }
+ // --- Loot collection ---
+ for (var i = 0; i < houses.length; i++) {
+ var h = houses[i];
+ if (h.hasLoot && h.loot && player.intersects(h.loot)) {
+ h.takeLoot();
+ // Score
+ score += 20;
+ scoreTxt.setText(score);
+ // Win if all loot collected and all zombies dead
+ if (zombies.length === 0 && allLootCollected()) {
+ LK.showYouWin();
+ gameOver = true;
+ return;
+ }
+ }
+ }
+};
+// --- Helper: all loot collected? ---
+function allLootCollected() {
+ for (var i = 0; i < houses.length; i++) {
+ if (houses[i].hasLoot) return false;
+ }
+ return true;
+}
\ No newline at end of file
katana. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
zombie. In-Game asset. High contrast. No shadows. 2d
Terk edilmiş ev. In-Game asset. 2d. High contrast. No shadows
Women. In-Game asset. 2d. High contrast. No shadows
erzak. In-Game asset. 2d. High contrast. No shadows
kan efekti. In-Game asset. 2d. High contrast. No shadows
start game button. In-Game asset. 2d. High contrast. No shadows