User prompt
Please fix the bug: 'Cannot read properties of null (reading 'setText')' in or related to this line: 'scoreTxt.setText(LK.getScore());' Line Number: 774
User prompt
Please fix the bug: 'Cannot read properties of null (reading 'setText')' in or related to this line: 'scoreTxt.setText(LK.getScore());' Line Number: 772
User prompt
Please fix the bug: 'scoreTxt is not defined' in or related to this line: 'scoreTxt.setText(LK.getScore());' Line Number: 771
User prompt
Please fix the bug: 'attackTxt is not defined' in or related to this line: 'if (attackTxt) {' Line Number: 546
User prompt
Please fix the bug: 'Cannot read properties of null (reading 'updateAttackType')' in or related to this line: 'player.updateAttackType(score);' Line Number: 543
User prompt
Please fix the bug: 'Cannot read properties of null (reading 'setText')' in or related to this line: 'livesTxt.setText('');' Line Number: 549
User prompt
Please fix the bug: 'livesTxt is not defined' in or related to this line: 'livesTxt.setText('');' Line Number: 549
User prompt
Please fix the bug: 'livesTxt is not defined' in or related to this line: 'livesTxt.setText('');' Line Number: 548
User prompt
Please fix the bug: 'Cannot read properties of null (reading 'lives')' in or related to this line: 'for (var i = 0; i < player.lives; i++) {' Line Number: 548
User prompt
Please fix the bug: 'attackTxt is not defined' in or related to this line: 'LK.gui.topLeft.addChild(attackTxt);' Line Number: 467
User prompt
oyun başlarken 2 adet zombi ve 2 adet ana karakter olacak ve bunlar arasında seçim yaparak oyuna başlanacak
User prompt
fix bug
User prompt
Please fix the bug: 'Uncaught TypeError: tween.create is not a function' in or related to this line: 'tween.create(fartAnim).to({' Line Number: 307
User prompt
Please fix the bug: 'Uncaught TypeError: tween.Tween is not a constructor' in or related to this line: 'new tween.Tween(fartAnim).to({' Line Number: 307
User prompt
Please fix the bug: 'Uncaught TypeError: tween.create is not a function' in or related to this line: 'tween.create(fartAnim).to({' Line Number: 307
User prompt
her 10 saniyede bir yukardan kalkan özelliği gelecek
User prompt
Remove shield if it takes a single hit, regardless of score
User prompt
kalkan tek bir can olacak ve hasar yediğinde kaybolacak
User prompt
kalkan saldırı alınca kaybolacak
User prompt
0 ile 150 puan arasında önünde 1 canlık kalkan olacak
User prompt
her 150 puanda bir ekstra can kazanıcak
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(fartAnim, {' Line Number: 262
User prompt
add fart animation
User prompt
zombileri vurdugunda zombiden ses gelecek
User prompt
her bir saldırıya ayrı ses efekleri koyalım ve zombilerin kusmukları biraz yavaş gelsin
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Fart = Container.expand(function () { var self = Container.call(this); var gfx = self.attachAsset('fart', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.update = function () { self.y += self.speed; }; return self; }); // Oyuncu karakteri var Player = Container.expand(function () { var self = Container.call(this); var playerGfx = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.radius = playerGfx.width / 2; self.cooldown = 0; // Atış bekleme süresi self.canAttack = true; self.lives = 3; self.attackType = 'poop'; // Başlangıç saldırısı self.unlockedAttacks = { poop: true, vomit: false, fart: false, snot: false }; // Saldırı tipini güncelle self.updateAttackType = function (score) { if (score >= 450 && !self.unlockedAttacks.snot) { self.unlockedAttacks.snot = true; LK.getSound('unlock').play(); } if (score >= 300 && !self.unlockedAttacks.fart) { self.unlockedAttacks.fart = true; LK.getSound('unlock').play(); } if (score >= 150 && !self.unlockedAttacks.vomit) { self.unlockedAttacks.vomit = true; LK.getSound('unlock').play(); } // Saldırı tipi otomatik değişmesin, oyuncu seçsin (ileride eklenebilir) }; return self; }); // Oyuncu saldırıları var Poop = Container.expand(function () { var self = Container.call(this); var gfx = self.attachAsset('poop', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -22; self.update = function () { self.y += self.speed; }; return self; }); // Kalkan powerup sınıfı var ShieldPowerup = Container.expand(function () { var self = Container.call(this); var gfx = self.attachAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2, alpha: 0.7 }); self.speed = 8; self.update = function () { self.y += self.speed; }; return self; }); // Kalkan powerup üretici var Snot = Container.expand(function () { var self = Container.call(this); var gfx = self.attachAsset('snot', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -30; self.update = function () { self.y += self.speed; }; return self; }); var Vomit = Container.expand(function () { var self = Container.call(this); var gfx = self.attachAsset('vomit', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -16; self.update = function () { self.y += self.speed; }; return self; }); // Zombi var Zombie = Container.expand(function () { var self = Container.call(this); var zombieGfx = self.attachAsset('zombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2 + Math.random() * 1.5; // Rastgele yavaş hız self.vomitCooldown = 90 + Math.floor(Math.random() * 120); // 1.5-3.5 sn arası kusma self.vomitTimer = 0; self.isDead = false; self.update = function () { self.y += self.speed; self.vomitTimer++; }; return self; }); // Zombinin kusmuğu var ZombieVomit = Container.expand(function () { var self = Container.call(this); var gfx = self.attachAsset('zombieVomit', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 6; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ // Müzik başlat // Zombi, karakter ve saldırı tipleri için temel şekiller tanımlanıyor LK.playMusic('bgmusic'); // Arka plan banyo resmi ekle var bgBathroom = LK.getAsset('bathroomBg', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732 }); game.addChild(bgBathroom); // Oyun alanı boyutları var GAME_W = 2048; var GAME_H = 2732; // --- SEÇİM EKRANI DEĞİŞKENLERİ --- var characterOptions = [{ id: 'player', name: 'Yalo', color: 0xffffff }, { id: 'player', name: 'Oso', color: 0xffe066 }]; var zombieOptions = [{ id: 'zombie', name: 'Zombi 1', color: 0xffffff }, { id: 'zombie', name: 'Zombi 2', color: 0x99ff99 }]; var selectedCharacterIdx = 0; var selectedZombieIdx = 0; var selectionActive = true; var selectionOverlay = new Container(); game.addChild(selectionOverlay); // Seçim ekranı arka planı var selBg = LK.getAsset('bathroomBg', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: GAME_W, height: GAME_H }); selectionOverlay.addChild(selBg); // Başlık var selTitle = new Text2('Karakter ve Zombi Seç!', { size: 120, fill: "#fff" }); selTitle.anchor.set(0.5, 0); selTitle.x = GAME_W / 2; selTitle.y = 120; selectionOverlay.addChild(selTitle); // Karakter seçenekleri var charSelNodes = []; for (var i = 0; i < characterOptions.length; i++) { var opt = characterOptions[i]; var node = LK.getAsset(opt.id, { anchorX: 0.5, anchorY: 0.5, x: GAME_W / 2 - 350 + i * 700, y: GAME_H / 2 - 200, tint: opt.color, scaleX: 1.2, scaleY: 1.2 }); selectionOverlay.addChild(node); charSelNodes.push(node); var label = new Text2(opt.name, { size: 80, fill: "#fff" }); label.anchor.set(0.5, 0); label.x = node.x; label.y = node.y + 180; selectionOverlay.addChild(label); } // Zombi seçenekleri var zombieSelNodes = []; for (var i = 0; i < zombieOptions.length; i++) { var opt = zombieOptions[i]; var node = LK.getAsset(opt.id, { anchorX: 0.5, anchorY: 0.5, x: GAME_W / 2 - 350 + i * 700, y: GAME_H / 2 + 350, tint: opt.color, scaleX: 1.2, scaleY: 1.2 }); selectionOverlay.addChild(node); zombieSelNodes.push(node); var label = new Text2(opt.name, { size: 80, fill: "#fff" }); label.anchor.set(0.5, 0); label.x = node.x; label.y = node.y + 180; selectionOverlay.addChild(label); } // Seçim kutuları var charBox = LK.getAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, x: charSelNodes[0].x, y: charSelNodes[0].y, scaleX: 1.5, scaleY: 1.5, alpha: 0.25 }); selectionOverlay.addChild(charBox); var zombieBox = LK.getAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, x: zombieSelNodes[0].x, y: zombieSelNodes[0].y, scaleX: 1.5, scaleY: 1.5, alpha: 0.25 }); selectionOverlay.addChild(zombieBox); // Başlat butonu var startBtn = new Text2('Başla', { size: 120, fill: 0x00FF99 }); startBtn.anchor.set(0.5, 0.5); startBtn.x = GAME_W / 2; startBtn.y = GAME_H - 350; selectionOverlay.addChild(startBtn); // Seçim ekranı dokunma işlemleri selectionOverlay.down = function (x, y, obj) { // Karakter seçimi for (var i = 0; i < charSelNodes.length; i++) { var node = charSelNodes[i]; if (Math.abs(x - node.x) < 180 && Math.abs(y - node.y) < 180) { selectedCharacterIdx = i; charBox.x = node.x; charBox.y = node.y; LK.getSound('unlock').play(); } } // Zombi seçimi for (var i = 0; i < zombieSelNodes.length; i++) { var node = zombieSelNodes[i]; if (Math.abs(x - node.x) < 180 && Math.abs(y - node.y) < 180) { selectedZombieIdx = i; zombieBox.x = node.x; zombieBox.y = node.y; LK.getSound('unlock').play(); } } // Başlat if (Math.abs(x - startBtn.x) < 300 && Math.abs(y - startBtn.y) < 100) { selectionActive = false; selectionOverlay.visible = false; // Oyun başlatılıyor! startGameWithSelections(); } }; game.addChild(selectionOverlay); game.down = function (x, y, obj) { if (selectionActive) { selectionOverlay.down(x, y, obj); return; } if (!(Math.abs(x - player.x) < 120 && Math.abs(y - player.y) < 120)) { // Saldırı if (player.canAttack) { spawnPlayerAttack(); player.canAttack = false; // Saldırı bekleme süresi saldırı tipine göre değişir var cd = 18; if (player.attackType === 'vomit') cd = 28; if (player.attackType === 'fart') cd = 36; if (player.attackType === 'snot') cd = 50; player.cooldown = cd; } } }; // --- OYUN BAŞLATMA FONKSİYONU --- function startGameWithSelections() { // Skor ve can göstergeleri var scoreTxt = new Text2('0', { size: 110, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var livesTxt = new Text2('❤❤❤', { size: 90, fill: 0xFF4444 }); livesTxt.anchor.set(1, 0); LK.gui.topRight.addChild(livesTxt); // Saldırı tipi göstergesi var attackTxt = new Text2('Kaka', { size: 80, fill: 0xFFE066 }); attackTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(attackTxt); // Oyuncu karakteri player = new Player(); player.x = GAME_W / 2; player.y = GAME_H - 350; game.addChild(player); // Karakter seçimine göre renk/tint uygula var charOpt = characterOptions[selectedCharacterIdx]; if (charOpt.color !== 0xffffff) { player.children[0].tint = charOpt.color; } // Kalkan görseli (ilk başta görünür, 0-150 puan arası) shieldAsset = LK.getAsset('centerCircle', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.2, scaleY: 2.2, alpha: 0.45, x: 0, y: 0 }); player.addChild(shieldAsset); player.shieldActive = true; shieldAsset.visible = true; // Zombiler ve saldırılar için diziler zombies = []; playerAttacks = []; zombieAttacks = []; shieldPowerups = []; dragNode = null; // İlk zombi, seçime göre for (var i = 0; i < 2; i++) { var z = new Zombie(); z.x = 180 + Math.random() * (GAME_W - 360); z.y = -100 - i * 200; // Zombi seçimine göre renk/tint uygula var zOpt = zombieOptions[selectedZombieIdx]; if (zOpt.color !== 0xffffff) { z.children[0].tint = zOpt.color; } zombies.push(z); game.addChild(z); } // 2 karakter varmış gibi göstermek için (ama sadece 1 oynanıyor) // (İkinci karakter dummy olarak eklenebilir, istenirse) // Skor, can, saldırı tipi güncelle updateLives(); updateAttackUnlocks(); scoreTxt.setText(LK.getScore()); attackTxt.setText(attackNames[player.attackType]); } // --- OYUN BAŞLANGICINDA SEÇİM EKRANI GÖRÜNÜR, OYUN BAŞLAMAZ --- var player = null; var shieldAsset = null; var zombies = []; var playerAttacks = []; var zombieAttacks = []; var shieldPowerups = []; var dragNode = null; // Kalkan powerup üretici function spawnShieldPowerup() { var p = new ShieldPowerup(); p.x = 180 + Math.random() * (GAME_W - 360); p.y = -80; shieldPowerups.push(p); game.addChild(p); } // Her 10 saniyede bir kalkan powerup üret LK.setInterval(function () { spawnShieldPowerup(); }, 10000); // Saldırı tipleri ve isimleri var attackTypes = ['poop', 'vomit', 'fart', 'snot']; var attackNames = { poop: 'Kaka', vomit: 'Kusmuk', fart: 'Osuruk', snot: 'Sümük' }; // Saldırı tipi göstergesi sadece bilgi amaçlı, tıklama ile değişmez // attackTxt is defined and added in startGameWithSelections, so this line is not needed here. // Zombi oluşturucu function spawnZombie() { var z = new Zombie(); z.x = 180 + Math.random() * (GAME_W - 360); z.y = -100; zombies.push(z); game.addChild(z); } // Zombi saldırısı oluşturucu function spawnZombieVomit(zombie) { var zv = new ZombieVomit(); zv.x = zombie.x; zv.y = zombie.y + 80; zombieAttacks.push(zv); game.addChild(zv); LK.getSound('zombieVomit').play(); } // Saldırı oluşturucu function spawnPlayerAttack() { var atk; var score = LK.getScore(); if (score < 150) { atk = new Poop(); player.attackType = 'poop'; } else if (score < 300) { atk = new Vomit(); player.attackType = 'vomit'; } else if (score < 400) { atk = new Fart(); player.attackType = 'fart'; } else { atk = new Snot(); player.attackType = 'snot'; } atk.x = player.x; atk.y = player.y - 90; playerAttacks.push(atk); game.addChild(atk); // Fart animation effect if (player.attackType === 'fart') { var fartAnim = LK.getAsset('fart', { anchorX: 0.5, anchorY: 0.5, x: player.x, y: player.y - 60, alpha: 0.8, scaleX: 1.2 + Math.random() * 0.5, scaleY: 1.2 + Math.random() * 0.5 }); game.addChild(fartAnim); tween.create(fartAnim).to({ alpha: 0, scaleX: 2, scaleY: 2, y: fartAnim.y - 80 }, 500).onComplete(function () { fartAnim.destroy(); }).start(); } // Play sound based on attack type if (player.attackType === 'poop') { LK.getSound('attackPoop').play(); } else if (player.attackType === 'vomit') { LK.getSound('attackVomit').play(); } else if (player.attackType === 'fart') { LK.getSound('attackFart').play(); } else if (player.attackType === 'snot') { LK.getSound('attackSnot').play(); } attackTxt.setText(attackNames[player.attackType]); } // Saldırı tipi güncelleme function updateAttackUnlocks() { var score = LK.getScore(); player.updateAttackType(score); attackTxt.setText(attackNames[player.attackType]); } // Can güncelle function updateLives() { if (!player || typeof player.lives !== "number") { livesTxt.setText(''); return; } var s = ''; for (var i = 0; i < player.lives; i++) s += '❤'; livesTxt.setText(s); } // Sürükleme ve hareket function handleMove(x, y, obj) { // Sadece yatay (X) eksende hareket etsin, Y sabit kalsın var px = Math.max(120, Math.min(GAME_W - 120, x)); player.x = px; // Y ekseni sabit, başlangıç konumunda kalacak } game.move = handleMove; // Ekrana dokununca saldırı (karaktere dokunulmazsa) game.down = function (x, y, obj) { if (!(Math.abs(x - player.x) < 120 && Math.abs(y - player.y) < 120)) { // Saldırı if (player.canAttack) { spawnPlayerAttack(); player.canAttack = false; // Saldırı bekleme süresi saldırı tipine göre değişir var cd = 18; if (player.attackType === 'vomit') cd = 28; if (player.attackType === 'fart') cd = 36; if (player.attackType === 'snot') cd = 50; player.cooldown = cd; } } }; game.up = function (x, y, obj) {}; // Oyun döngüsü game.update = function () { // Saldırı bekleme if (!player.canAttack) { player.cooldown--; if (player.cooldown <= 0) { player.canAttack = true; } } // Kalkan aktifliği güncelle (sadece bir kez alınan hasarla kaybolur) if (player.shieldActive) { if (player.children.indexOf(shieldAsset) === -1) player.addChild(shieldAsset); shieldAsset.visible = true; } else { shieldAsset.visible = false; if (player.children.indexOf(shieldAsset) !== -1) player.removeChild(shieldAsset); } // Zombiler for (var i = zombies.length - 1; i >= 0; i--) { var z = zombies[i]; z.update(); // Zombi ekrandan çıktıysa if (z.y > GAME_H + 100) { z.destroy(); zombies.splice(i, 1); continue; } // Zombi oyuncuya çarptı mı? if (!z.isDead && z.intersects(player)) { z.isDead = true; z.destroy(); zombies.splice(i, 1); if (player.shieldActive) { // Kalkan varsa hasar alma, kalkanı kısa süreliğine parlat LK.effects.flashObject(shieldAsset, 0x00ffff, 400); // Kalkan saldırı alınca kaybolacak player.shieldActive = false; shieldAsset.visible = false; if (player.children.indexOf(shieldAsset) !== -1) player.removeChild(shieldAsset); } else { player.lives--; updateLives(); LK.effects.flashObject(player, 0xff0000, 600); if (player.lives <= 0) { LK.effects.flashScreen(0xff0000, 1200); LK.showGameOver(); return; } } continue; } // Zombi kusacak mı? if (z.vomitTimer >= z.vomitCooldown) { spawnZombieVomit(z); z.vomitTimer = 0; z.vomitCooldown = 90 + Math.floor(Math.random() * 120); } } // Oyuncu saldırıları for (var i = playerAttacks.length - 1; i >= 0; i--) { var atk = playerAttacks[i]; atk.update(); // Ekrandan çıktıysa if (atk.y < -100) { atk.destroy(); playerAttacks.splice(i, 1); continue; } // Zombiye çarptı mı? for (var j = zombies.length - 1; j >= 0; j--) { var z = zombies[j]; if (!z.isDead && atk.intersects(z)) { z.isDead = true; LK.getSound('attack').play(); z.destroy(); zombies.splice(j, 1); atk.destroy(); playerAttacks.splice(i, 1); // Skor var prevScore = LK.getScore(); LK.setScore(prevScore + 10); scoreTxt.setText(LK.getScore()); updateAttackUnlocks(); // Ekstra can: Her 150 puanda bir ekstra can kazan var newScore = LK.getScore(); if (Math.floor(prevScore / 150) < Math.floor(newScore / 150)) { player.lives++; updateLives(); LK.getSound('unlock').play(); } // Kazanma yok, amaç hayatta kalmak break; } } } // Zombi saldırıları for (var i = zombieAttacks.length - 1; i >= 0; i--) { var zv = zombieAttacks[i]; zv.update(); // Ekrandan çıktıysa if (zv.y > GAME_H + 100) { zv.destroy(); zombieAttacks.splice(i, 1); continue; } // Oyuncuya çarptı mı? if (zv.intersects(player)) { zv.destroy(); zombieAttacks.splice(i, 1); if (player.shieldActive) { // Kalkan varsa hasar alma, kalkanı kısa süreliğine parlat LK.effects.flashObject(shieldAsset, 0x00ffff, 400); // Kalkan saldırı alınca kaybolacak player.shieldActive = false; shieldAsset.visible = false; if (player.children.indexOf(shieldAsset) !== -1) player.removeChild(shieldAsset); } else { player.lives--; updateLives(); LK.effects.flashObject(player, 0x00ff00, 600); if (player.lives <= 0) { LK.effects.flashScreen(0xff0000, 1200); LK.showGameOver(); return; } } continue; } } // Zombi üretimi (her 60-90 tickte bir) if (LK.ticks % (60 + Math.floor(Math.random() * 30)) === 0) { if (zombies.length < 7) spawnZombie(); } // Kalkan powerup hareket ve toplama for (var i = shieldPowerups.length - 1; i >= 0; i--) { var p = shieldPowerups[i]; p.update(); // Ekrandan çıktıysa if (p.y > GAME_H + 100) { p.destroy(); shieldPowerups.splice(i, 1); continue; } // Oyuncuya çarptı mı? if (p.intersects(player)) { p.destroy(); shieldPowerups.splice(i, 1); // Kalkanı aktif et player.shieldActive = true; if (player.children.indexOf(shieldAsset) === -1) player.addChild(shieldAsset); shieldAsset.visible = true; LK.getSound('unlock').play(); // Kısa bir parlama efekti LK.effects.flashObject(shieldAsset, 0x00ffff, 400); continue; } } }; // Oyun başında ilk zombi spawnZombie(); updateLives(); updateAttackUnlocks(); scoreTxt.setText(LK.getScore()); attackTxt.setText(attackNames[player.attackType]);
===================================================================
--- original.js
+++ change.js
@@ -516,8 +516,12 @@
attackTxt.setText(attackNames[player.attackType]);
}
// Can güncelle
function updateLives() {
+ if (!player || typeof player.lives !== "number") {
+ livesTxt.setText('');
+ return;
+ }
var s = '';
for (var i = 0; i < player.lives; i++) s += '❤';
livesTxt.setText(s);
}
poop. In-Game asset. 2d. High contrast. No shadows
vomit. In-Game asset. 2d. High contrast. No shadows
bathrom. In-Game asset. 2d. High contrast. No shadows
fart animation. In-Game asset. 2d. High contrast. No shadows
yuvarlak mavi elektirikli kalkan. In-Game asset. 2d. High contrast. No shadows
snot. In-Game asset. 2d. High contrast. No shadows
transparent