User prompt
Seviye içindeki kareleri kücült ve çoğalt
User prompt
Seviye içindeki bitki koyma alanini buyut
User prompt
Seviye içindeki görseller için yeni görseller çıkar
User prompt
Seviye içindindeki görselleri farkli yap
User prompt
Please fix the bug: 'ReferenceError: sunText is not defined' in or related to this line: 'sunText.setText('Sun: ' + sun);' Line Number: 183
User prompt
Başlık arka planı kalsın sadece başlığı kaldır
User prompt
Başlığı kaldır
User prompt
Plants vs zombies level collection yazısıni plants vs zombies oyunundaki yazilar gibi yao
User prompt
Arka plan rengi biraz daha koyu bir sayfa gibi olsun
User prompt
Arka plqnı kahverengi bir sayfa yaprağı yap
User prompt
Please fix the bug: 'ReferenceError: sun is not defined' in or related to this line: 'sun += 25;' Line Number: 181
User prompt
Please fix the bug: 'ReferenceError: plants is not defined' in or related to this line: 'for (var i = plants.length - 1; i >= 0; i--) {' Line Number: 219
User prompt
Level 1 e bastiğim zaman beni level birin içine göndersin
User prompt
Level 1 2 3 böyle gitsin
User prompt
Ekrandaki herşey kaldır ve planrs vs zombies bölum dizynini yap
User prompt
Gridhücresini karelere böl kareler büyük olaun
User prompt
Grid hücresini ve evi büyüt
User prompt
Evi uzat
User prompt
Evi büyüt
User prompt
Evi büyüt grid hücresi ile eşit yap
User prompt
Evin uzunluğunu gridhücresi ile aynı hizada yap
User prompt
Evin Uzunluğunu hücre ile aynı hizada yap
User prompt
Grid hicresini ve evi büyüt
User prompt
Grid hücresini kare kare alanlara böl
User prompt
Başlangıç parasını arttiŕ
/**** * Classes ****/ var Pea = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('pea', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.damage = 20; self.lane = 0; self.update = function () { self.x += self.speed; // Check collision with zombies in same lane for (var i = zombies.length - 1; i >= 0; i--) { var zombie = zombies[i]; if (zombie.lane === self.lane && self.intersects(zombie)) { zombie.takeDamage(self.damage); self.destroy(); break; } } // Remove if off screen if (self.x > 2048) { self.destroy(); } }; return self; }); var Plant = Container.expand(function () { var self = Container.call(this); self.gridX = 0; self.gridY = 0; self.lane = 0; self.health = 100; self.maxHealth = 100; self.type = 'basic'; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { self.destroy(); } }; self.destroy = function () { // Remove from grid if (gameGrid[self.gridY] && gameGrid[self.gridY][self.gridX]) { gameGrid[self.gridY][self.gridX] = null; } Container.prototype.destroy.call(self); }; return self; }); var Wallnut = Plant.expand(function () { var self = Plant.call(this); var graphics = self.attachAsset('wallnut', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'wallnut'; self.health = 300; self.maxHealth = 300; self.update = function () { // Update visual based on health var healthPercent = self.health / self.maxHealth; if (healthPercent < 0.3) { graphics.tint = 0x8B0000; // Dark red when damaged } else if (healthPercent < 0.6) { graphics.tint = 0xCD853F; // Brown when moderately damaged } }; return self; }); var Sunflower = Plant.expand(function () { var self = Plant.call(this); var graphics = self.attachAsset('sunflower', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'sunflower'; self.sunTimer = 0; self.sunInterval = 300; // 5 seconds at 60fps self.update = function () { self.sunTimer++; if (self.sunTimer >= self.sunInterval) { self.sunTimer = 0; self.generateSun(); } }; self.generateSun = function () { var sun = new Sunlight(); sun.x = self.x + (Math.random() - 0.5) * 60; sun.y = self.y + (Math.random() - 0.5) * 60; sunlights.push(sun); game.addChild(sun); }; return self; }); var Shooter = Plant.expand(function () { var self = Plant.call(this); var graphics = self.attachAsset('shooter', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'shooter'; self.shootTimer = 0; self.shootInterval = 60; // 1 second at 60fps self.update = function () { // Check if there's a zombie in this lane var zombieInLane = false; for (var i = 0; i < zombies.length; i++) { if (zombies[i].lane === self.lane && zombies[i].x > self.x) { zombieInLane = true; break; } } if (zombieInLane) { self.shootTimer++; if (self.shootTimer >= self.shootInterval) { self.shootTimer = 0; self.shoot(); } } }; self.shoot = function () { var pea = new Pea(); pea.x = self.x + 40; pea.y = self.y; pea.lane = self.lane; peas.push(pea); game.addChild(pea); LK.getSound('shoot').play(); }; return self; }); var Peashooter = Plant.expand(function () { var self = Plant.call(this); var graphics = self.attachAsset('peashooter', { anchorX: 0.5, anchorY: 0.5 }); self.type = 'peashooter'; self.shootTimer = 0; self.shootInterval = 90; // 1.5 seconds at 60fps self.update = function () { // Check if there's a zombie in this lane var zombieInLane = false; for (var i = 0; i < zombies.length; i++) { if (zombies[i].lane === self.lane && zombies[i].x > self.x) { zombieInLane = true; break; } } if (zombieInLane) { self.shootTimer++; if (self.shootTimer >= self.shootInterval) { self.shootTimer = 0; self.shoot(); } } }; self.shoot = function () { var pea = new Pea(); pea.x = self.x + 40; pea.y = self.y; pea.lane = self.lane; peas.push(pea); game.addChild(pea); LK.getSound('shoot').play(); }; return self; }); var Sunlight = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('sunlight', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.lifeTime = 0; self.maxLifeTime = 600; // 10 seconds at 60fps self.update = function () { self.lifeTime++; if (self.lifeTime > self.maxLifeTime && !self.collected) { self.destroy(); } }; self.down = function (x, y, obj) { if (!self.collected) { self.collected = true; sunlightCount += 25; updateSunlightDisplay(); LK.getSound('collect').play(); self.destroy(); } }; return self; }); var Zombie = Container.expand(function () { var self = Container.call(this); self.speed = 1; self.health = 100; self.damage = 20; self.lane = 0; self.attackTimer = 0; self.attackInterval = 60; // 1 second at 60fps self.isAttacking = false; self.update = function () { if (!self.isAttacking) { self.x -= self.speed; // Check for collision with plants var plantToAttack = null; for (var row = 0; row < gameGrid.length; row++) { for (var col = 0; col < gameGrid[row].length; col++) { var plant = gameGrid[row][col]; if (plant && plant.lane === self.lane && self.intersects(plant)) { plantToAttack = plant; break; } } if (plantToAttack) break; } if (plantToAttack) { self.isAttacking = true; self.attackTarget = plantToAttack; } } else { // Attack mode self.attackTimer++; if (self.attackTimer >= self.attackInterval) { self.attackTimer = 0; if (self.attackTarget && !self.attackTarget.destroyed) { self.attackTarget.takeDamage(self.damage); if (self.attackTarget.health <= 0) { self.isAttacking = false; self.attackTarget = null; } } else { self.isAttacking = false; self.attackTarget = null; } } } // Check if reached house if (self.x < 50) { // Damage house and remove zombie houseHealth -= self.damage; updateHouseHealth(); self.destroy(); // Check if house is destroyed if (houseHealth <= 0) { LK.showGameOver(); } } }; self.takeDamage = function (damage) { self.health -= damage; if (self.health <= 0) { LK.getSound('zombieDie').play(); self.destroy(); } }; self.destroy = function () { // Remove from zombies array for (var i = zombies.length - 1; i >= 0; i--) { if (zombies[i] === self) { zombies.splice(i, 1); break; } } Container.prototype.destroy.call(self); }; return self; }); var FastZombie = Zombie.expand(function () { var self = Zombie.call(this); var graphics = self.attachAsset('fastZombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1.5; self.health = 60; return self; }); // Game state variables var BasicZombie = Zombie.expand(function () { var self = Zombie.call(this); var graphics = self.attachAsset('basicZombie', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0.8; self.health = 100; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228B22 // Forest green background }); /**** * Game Code ****/ // Game state variables // Plant assets // Zombie assets // Projectile and resource assets // Grid and UI assets // Sound effects var sunlightCount = 150; var selectedPlantType = 'sunflower'; var justPurchased = false; var gameStarted = false; var waveNumber = 1; var zombiesSpawned = 0; var zombiesPerWave = 5; var waveTimer = 0; var waveInterval = 600; // 10 seconds between waves var houseHealth = 100; var maxHouseHealth = 100; // Game object arrays var plants = []; var zombies = []; var peas = []; var sunlights = []; // Shop variables var shopButtons = []; var shopStartY = 2400; var shopHeight = 200; // Grid system (5 lanes, 9 columns) var gameGrid = []; var gridStartX = 300; var gridStartY = 400; var cellWidth = 150; var cellHeight = 150; var gridRows = 10; var gridCols = 9; // Plant costs var plantCosts = { 'sunflower': 50, 'peashooter': 100, 'wallnut': 50, 'shooter': 50 }; // Initialize grid for (var row = 0; row < gridRows; row++) { gameGrid[row] = []; for (var col = 0; col < gridCols; col++) { gameGrid[row][col] = null; } } // Create visual grid with borders for (var row = 0; row < gridRows; row++) { for (var col = 0; col < gridCols; col++) { var cell = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, alpha: 0.3 }); cell.x = gridStartX + col * cellWidth; cell.y = gridStartY + row * cellHeight; cell.gridRow = row; cell.gridCol = col; game.addChild(cell); // Add border lines to create clear square divisions // Top border var topBorder = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, width: cellWidth, height: 2 }); topBorder.x = gridStartX + col * cellWidth; topBorder.y = gridStartY + row * cellHeight - cellHeight / 2; topBorder.tint = 0x000000; game.addChild(topBorder); // Left border var leftBorder = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, width: 2, height: cellHeight }); leftBorder.x = gridStartX + col * cellWidth - cellWidth / 2; leftBorder.y = gridStartY + row * cellHeight; leftBorder.tint = 0x000000; game.addChild(leftBorder); // Right border for last column if (col === gridCols - 1) { var rightBorder = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, width: 2, height: cellHeight }); rightBorder.x = gridStartX + col * cellWidth + cellWidth / 2; rightBorder.y = gridStartY + row * cellHeight; rightBorder.tint = 0x000000; game.addChild(rightBorder); } // Bottom border for last row if (row === gridRows - 1) { var bottomBorder = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, width: cellWidth, height: 2 }); bottomBorder.x = gridStartX + col * cellWidth; bottomBorder.y = gridStartY + row * cellHeight + cellHeight / 2; bottomBorder.tint = 0x000000; game.addChild(bottomBorder); } } } // Create house var house = LK.getAsset('house', { anchorX: 0.5, anchorY: 0.5 }); house.x = 75; house.y = gridStartY + gridRows * cellHeight / 2; game.addChild(house); // Create house health bar var healthBarBg = LK.getAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBarBg.x = house.x; healthBarBg.y = house.y - 450; game.addChild(healthBarBg); var healthBarFill = LK.getAsset('healthBarFill', { anchorX: 0, anchorY: 0.5 }); healthBarFill.x = house.x - 60; healthBarFill.y = house.y - 450; game.addChild(healthBarFill); var healthText = new Text2('House: ' + houseHealth + '/' + maxHouseHealth, { size: 30, fill: 0xFFFFFF }); healthText.anchor.set(0.5, 0.5); healthText.x = house.x; healthText.y = house.y - 480; game.addChild(healthText); // Create UI var sunlightDisplay = new Text2('Sun: ' + sunlightCount, { size: 60, fill: 0xFFD700 }); sunlightDisplay.anchor.set(1, 0); LK.gui.topRight.addChild(sunlightDisplay); var waveDisplay = new Text2('Wave: ' + waveNumber, { size: 50, fill: 0xFFFFFF }); waveDisplay.anchor.set(0.5, 0); LK.gui.top.addChild(waveDisplay); // Plant selection buttons var sunflowerBtn = new Text2('Sunflower (50)', { size: 40, fill: 0xFFD700 }); sunflowerBtn.anchor.set(1, 0); sunflowerBtn.x = -20; sunflowerBtn.y = 100; LK.gui.topRight.addChild(sunflowerBtn); var peashooterBtn = new Text2('Peashooter (100)', { size: 40, fill: 0x00FF00 }); peashooterBtn.anchor.set(1, 0); peashooterBtn.x = -20; peashooterBtn.y = 150; LK.gui.topRight.addChild(peashooterBtn); var wallnutBtn = new Text2('Wall-nut (50)', { size: 40, fill: 0x8B4513 }); wallnutBtn.anchor.set(1, 0); wallnutBtn.x = -20; wallnutBtn.y = 200; LK.gui.topRight.addChild(wallnutBtn); // Create shop at bottom of screen var shopBackground = LK.getAsset('shopBackground', { anchorX: 0.5, anchorY: 0.5 }); shopBackground.x = 1024; shopBackground.y = shopStartY + shopHeight / 2; game.addChild(shopBackground); // Create shop buttons for each plant type var shopPlantTypes = ['sunflower', 'peashooter', 'wallnut', 'shooter']; var shopPlantNames = ['Sunflower', 'Peashooter', 'Wall-nut', 'Shooter']; var shopPlantCosts = [50, 100, 50, 50]; for (var i = 0; i < shopPlantTypes.length; i++) { var shopBtn = LK.getAsset('shopButton', { anchorX: 0.5, anchorY: 0.5 }); shopBtn.x = 300 + i * 200; shopBtn.y = shopStartY + shopHeight / 2; shopBtn.plantType = shopPlantTypes[i]; shopBtn.cost = shopPlantCosts[i]; game.addChild(shopBtn); shopButtons.push(shopBtn); // Add text label for shop button var shopBtnText = new Text2(shopPlantNames[i] + '\n' + shopPlantCosts[i] + ' Sun', { size: 30, fill: 0xFFFFFF }); shopBtnText.anchor.set(0.5, 0.5); shopBtnText.x = shopBtn.x; shopBtnText.y = shopBtn.y; game.addChild(shopBtnText); shopBtn.textLabel = shopBtnText; } function updateSunlightDisplay() { sunlightDisplay.setText('Sun: ' + sunlightCount); // Update button colors based on affordability using tint property sunflowerBtn.tint = sunlightCount >= 50 ? 0xFFD700 : 0x666666; peashooterBtn.tint = sunlightCount >= 100 ? 0x00FF00 : 0x666666; wallnutBtn.tint = sunlightCount >= 50 ? 0x8B4513 : 0x666666; // Update shop button colors for (var i = 0; i < shopButtons.length; i++) { var btn = shopButtons[i]; if (sunlightCount >= btn.cost) { btn.tint = 0xFFFFFF; btn.textLabel.tint = 0xFFFFFF; } else { btn.tint = 0x666666; btn.textLabel.tint = 0x666666; } } } function updateHouseHealth() { // Update health bar fill width based on current health var healthPercent = houseHealth / maxHouseHealth; healthBarFill.width = 120 * healthPercent; // Update health bar color based on health level if (healthPercent <= 0.3) { healthBarFill.tint = 0xff0000; // Red when low health } else if (healthPercent <= 0.6) { healthBarFill.tint = 0xffff00; // Yellow when medium health } else { healthBarFill.tint = 0x00ff00; // Green when high health } // Update health text healthText.setText('House: ' + houseHealth + '/' + maxHouseHealth); } // Input handling game.down = function (x, y, obj) { // Check if clicking on shop buttons if (y >= shopStartY && y <= shopStartY + shopHeight) { for (var i = 0; i < shopButtons.length; i++) { var btn = shopButtons[i]; if (x >= btn.x - 75 && x <= btn.x + 75 && sunlightCount >= btn.cost) { // Purchase plant and set it as selected for placement sunlightCount -= btn.cost; selectedPlantType = btn.plantType; updateSunlightDisplay(); // Store that we just purchased this plant justPurchased = true; return; } } } // Check if clicking on plant selection buttons var localPos = LK.gui.topRight.toLocal({ x: x, y: y }); if (localPos.x >= -300 && localPos.x <= -20) { if (localPos.y >= 100 && localPos.y <= 140 && sunlightCount >= 50) { selectedPlantType = 'sunflower'; return; } else if (localPos.y >= 150 && localPos.y <= 190 && sunlightCount >= 100) { selectedPlantType = 'peashooter'; return; } else if (localPos.y >= 200 && localPos.y <= 240 && sunlightCount >= 50) { selectedPlantType = 'wallnut'; return; } } // Check if clicking on grid for plant placement var gridCol = Math.floor((x - gridStartX + cellWidth / 2) / cellWidth); var gridRow = Math.floor((y - gridStartY + cellHeight / 2) / cellHeight); if (gridCol >= 0 && gridCol < gridCols && gridRow >= 0 && gridRow < gridRows) { if (gameGrid[gridRow][gridCol] === null) { // If we just purchased from shop, place immediately without additional cost if (justPurchased) { placePlantFromShop(gridRow, gridCol, selectedPlantType); justPurchased = false; } else if (sunlightCount >= plantCosts[selectedPlantType]) { // Regular placement from selection buttons placePlant(gridRow, gridCol, selectedPlantType); } } } }; function placePlant(row, col, type) { var plant; switch (type) { case 'sunflower': plant = new Sunflower(); break; case 'peashooter': plant = new Peashooter(); break; case 'wallnut': plant = new Wallnut(); break; case 'shooter': plant = new Shooter(); break; default: return; } plant.gridX = col; plant.gridY = row; plant.lane = row; plant.x = gridStartX + col * cellWidth; plant.y = gridStartY + row * cellHeight; gameGrid[row][col] = plant; plants.push(plant); game.addChild(plant); sunlightCount -= plantCosts[type]; updateSunlightDisplay(); LK.getSound('plantPlace').play(); // Start the game when first plant is placed if (!gameStarted) { gameStarted = true; } } function placePlantFromShop(row, col, type) { var plant; switch (type) { case 'sunflower': plant = new Sunflower(); break; case 'peashooter': plant = new Peashooter(); break; case 'wallnut': plant = new Wallnut(); break; case 'shooter': plant = new Shooter(); break; default: return; } plant.gridX = col; plant.gridY = row; plant.lane = row; plant.x = gridStartX + col * cellWidth; plant.y = gridStartY + row * cellHeight; gameGrid[row][col] = plant; plants.push(plant); game.addChild(plant); // No additional cost since already paid in shop updateSunlightDisplay(); LK.getSound('plantPlace').play(); // Start the game when first plant is placed if (!gameStarted) { gameStarted = true; } } // Main game loop game.update = function () { // Only start spawning zombies after first plant is placed if (gameStarted) { // Update wave timer and spawn zombies waveTimer++; if (waveTimer >= waveInterval && zombiesSpawned < zombiesPerWave) { spawnZombie(); waveTimer = 0; zombiesSpawned++; if (zombiesSpawned >= zombiesPerWave && zombies.length === 0) { // Start next wave waveNumber++; zombiesPerWave = Math.min(10, 5 + waveNumber); zombiesSpawned = 0; waveDisplay.setText('Wave: ' + waveNumber); } } } // Clean up destroyed objects for (var i = peas.length - 1; i >= 0; i--) { if (peas[i].destroyed) { peas.splice(i, 1); } } for (var i = sunlights.length - 1; i >= 0; i--) { if (sunlights[i].destroyed) { sunlights.splice(i, 1); } } for (var i = plants.length - 1; i >= 0; i--) { if (plants[i].destroyed) { plants.splice(i, 1); } } // Check win condition (survived 10 waves) if (waveNumber > 10 && zombies.length === 0) { LK.showYouWin(); } }; function spawnZombie() { var zombie; // 70% chance for basic zombie, 30% for fast zombie if (Math.random() < 0.7) { zombie = new BasicZombie(); } else { zombie = new FastZombie(); } // Random lane var lane = Math.floor(Math.random() * gridRows); zombie.lane = lane; zombie.x = 2048 - 50; zombie.y = gridStartY + lane * cellHeight; zombies.push(zombie); game.addChild(zombie); }
===================================================================
--- original.js
+++ change.js
Kahverengi sayfa yaprağı. In-Game asset. 2d. High contrast. No shadows
Kağıdın içinde plants vs zombies yazsin
Plant vs zombies ay çiçeği. In-Game asset. 2d. High contrast. No shadows
boş buton. In-Game asset. 2d. High contrast. No shadows
plans vs zombies double shoters. In-Game asset. 2d. High contrast. No shadows
çöl. In-Game asset. 2d. High contrast. No shadows
buz arkaplan. In-Game asset. 2d. High contrast. No shadows
gece gökyüzü. In-Game asset. 2d. High contrast. No shadows
orman. In-Game asset. 2d. High contrast. No shadows
toprak arka plan. In-Game asset. 2d. High contrast. No shadows
plants vs zombies ceviz. In-Game asset. 2d. High contrast. No shadows
ıcepeasshooter plants vs zombies. In-Game asset. 2d. High contrast. No shadows
kankanlı zombi plants vs zombies. In-Game asset. 2d. High contrast. No shadows
plants vs zombies olü ceviz. In-Game asset. 2d. High contrast. No shadows
bombacı zombi plants vs zombies. In-Game asset. 2d. High contrast. No shadows