User prompt
Directly from the button not else
User prompt
Make we drag a defender by their button
User prompt
Make we can drag the cats by the button in the menu
User prompt
Place les chats que quand on lâche
User prompt
Make we can place cats anywhere near the path
User prompt
Make we can change place the cat we placed but only before game starts
User prompt
Now make normal cat still attack mice rally slowly but attack rats normally (as well as tired. Cats attacks mice(
User prompt
Add background to the game
User prompt
Remove all squares in the background
User prompt
Replace Packet health text by Croquet left
User prompt
Actually we can't drag cats and place them
User prompt
Remove all squares in background to make game prettier
User prompt
Fait qu'on doit glisser les défenseurs vers la place ou ont veut pas juste cliquer dessus puis mettre a la place
User prompt
Make that we drag the defenders to place them, not clicking then placing whiteout seeing it
User prompt
Before mice start coming, show start button and they only start coming when clicking on the start button
User prompt
After 10 secs show start button ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
In start button, add a image of tiredCat and an arrow and a mouse to explain
User prompt
Add bgMusic to the game
User prompt
Add tiger defender
User prompt
Make it more bigger
User prompt
Make wild cat and normal cat price bigger
User prompt
Make wild cat after normal cat in menu
User prompt
Add new defender, wild cat
User prompt
Make normal cats attacks slowly please
User prompt
NORMAL CAT DOIT ATTAQUER LES SOURIS TOUT DOUCEMENT PAS EN 1 COUP
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Mouse = Container.expand(function () { var self = Container.call(this); var mouseGraphics = self.attachAsset('mouse', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; self.speed = 1.5 + Math.random() * 1.5; // Random speed between 1.5 and 3 self.pathIndex = 0; self.reward = 10; // Create health bar components var healthBarBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBarBg.x = 0; healthBarBg.y = -50; var healthBarFill = self.attachAsset('healthBarFill', { anchorX: 0, anchorY: 0.5 }); healthBarFill.x = -35; healthBarFill.y = -50; self.updateHealthBar = function () { var healthPercent = self.health / self.maxHealth; healthBarFill.scaleX = healthPercent; // Change color based on health if (healthPercent > 0.6) { healthBarFill.tint = 0x00ff00; // Green } else if (healthPercent > 0.3) { healthBarFill.tint = 0xffff00; // Yellow } else { healthBarFill.tint = 0xff0000; // Red } }; self.update = function () { if (self.pathIndex < gamePath.length) { var target = gamePath[self.pathIndex]; var dx = target.x - self.x; var dy = target.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 10) { self.pathIndex++; if (self.pathIndex >= gamePath.length) { // Mouse reached the end - damage packet packetHealth -= 30; // Increased from 20 updatePacketDisplay(); LK.getSound('enemySteal').play(); if (packetHealth <= 0) { LK.showGameOver(); } self.destroy(); mice.splice(mice.indexOf(self), 1); return; } } else { // Flip scaleX based on movement direction like cats if (dx > 0) { mouseGraphics.scaleX = 1; // Face right } else if (dx < 0) { mouseGraphics.scaleX = -1; // Face left } self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } } }; self.takeDamage = function (damage) { self.health -= damage; self.updateHealthBar(); if (self.health <= 0) { // Mouse defeated - give reward gameGold += self.reward; updateGoldDisplay(); LK.getSound('mouseHit').play(); self.destroy(); mice.splice(mice.indexOf(self), 1); } }; return self; }); var Rat = Container.expand(function () { var self = Container.call(this); var ratGraphics = self.attachAsset('rat', { anchorX: 0.5, anchorY: 0.5 }); self.health = 200; self.maxHealth = 200; self.speed = 2.5 + Math.random() * 1.5; // Faster than mice self.pathIndex = 0; self.reward = 25; // Higher reward // Create health bar components var healthBarBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBarBg.x = 0; healthBarBg.y = -60; var healthBarFill = self.attachAsset('healthBarFill', { anchorX: 0, anchorY: 0.5 }); healthBarFill.x = -35; healthBarFill.y = -60; self.updateHealthBar = function () { var healthPercent = self.health / self.maxHealth; healthBarFill.scaleX = healthPercent; // Change color based on health if (healthPercent > 0.6) { healthBarFill.tint = 0x00ff00; // Green } else if (healthPercent > 0.3) { healthBarFill.tint = 0xffff00; // Yellow } else { healthBarFill.tint = 0xff0000; // Red } }; self.update = function () { if (self.pathIndex < gamePath.length) { var target = gamePath[self.pathIndex]; var dx = target.x - self.x; var dy = target.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 10) { self.pathIndex++; if (self.pathIndex >= gamePath.length) { // Rat reached the end - damage packet more packetHealth -= 60; // Increased from 40 updatePacketDisplay(); LK.getSound('enemySteal').play(); if (packetHealth <= 0) { LK.showGameOver(); } self.destroy(); rats.splice(rats.indexOf(self), 1); return; } } else { // Flip scaleX based on movement direction like cats if (dx > 0) { ratGraphics.scaleX = 1; // Face right } else if (dx < 0) { ratGraphics.scaleX = -1; // Face left } self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } } }; self.takeDamage = function (damage) { self.health -= damage; self.updateHealthBar(); if (self.health <= 0) { // Rat defeated - give reward gameGold += self.reward; updateGoldDisplay(); LK.getSound('mouseHit').play(); self.destroy(); rats.splice(rats.indexOf(self), 1); } }; return self; }); var Tower = Container.expand(function (type) { var self = Container.call(this); var towerGraphics; self.type = type || 'tired'; self.range = 250; self.damage = 18; // Reduced from 25 self.fireRate = 30; // frames between shots (0.5 seconds at 60fps) self.lastShot = 0; if (self.type === 'tired') { towerGraphics = self.attachAsset('tiredCat', { anchorX: 0.5, anchorY: 0.5 }); self.cost = 50; self.fireRate = 60; // Slower attack rate for tired cats } else if (self.type === 'normal') { towerGraphics = self.attachAsset('normalCat', { anchorX: 0.5, anchorY: 0.5 }); self.damage = 28; // Reduced from 40 self.range = 280; self.cost = 250; self.fireRate = 30; } else if (self.type === 'strong') { towerGraphics = self.attachAsset('strongCat', { anchorX: 0.5, anchorY: 0.5 }); self.damage = 35; // Reduced from 50 self.range = 300; self.cost = 100; self.fireRate = 30; } else if (self.type === 'strongest') { towerGraphics = self.attachAsset('strongestCat', { anchorX: 0.5, anchorY: 0.5 }); self.damage = 70; // Reduced from 100 self.range = 350; self.fireRate = 30; self.cost = 200; } else if (self.type === 'wild') { towerGraphics = self.attachAsset('wildCat', { anchorX: 0.5, anchorY: 0.5 }); self.damage = 50; self.range = 320; self.fireRate = 20; // Faster than other cats self.cost = 300; } else if (self.type === 'tiger') { towerGraphics = self.attachAsset('tiger', { anchorX: 0.5, anchorY: 0.5 }); self.damage = 80; self.range = 400; self.fireRate = 15; // Very fast attack rate self.cost = 500; } self.update = function () { self.lastShot++; var target = self.findTarget(); if (target) { var currentFireRate = self.fireRate; // Normal cat attacks slowly against mice but faster against rats if (self.type === 'normal') { if (target.constructor.name === 'Mouse') { currentFireRate = 600; // Extremely slow against mice - 10 seconds between shots } else if (target.constructor.name === 'Rat') { currentFireRate = 15; // Fast against rats } } if (self.lastShot >= currentFireRate) { self.shoot(target); self.lastShot = 0; } } }; self.findTarget = function () { var closestEnemy = null; var closestDistance = self.range; // Check mice for (var i = 0; i < mice.length; i++) { var mouse = mice[i]; var distance = Math.sqrt(Math.pow(mouse.x - self.x, 2) + Math.pow(mouse.y - self.y, 2)); if (distance < closestDistance) { closestEnemy = mouse; closestDistance = distance; } } // Check rats for (var i = 0; i < rats.length; i++) { var rat = rats[i]; var distance = Math.sqrt(Math.pow(rat.x - self.x, 2) + Math.pow(rat.y - self.y, 2)); if (distance < closestDistance) { closestEnemy = rat; closestDistance = distance; } } return closestEnemy; }; self.shoot = function (target) { // Flip scaleX based on enemy position when shooting var dx = target.x - self.x; var dy = target.y - self.y; // Flip horizontally based on enemy position var originalScaleX = 1; if (dx > 0) { originalScaleX = 1; // Face right towerGraphics.scaleX = 1; } else if (dx < 0) { originalScaleX = -1; // Face left towerGraphics.scaleX = -1; } // Instant damage instead of bullets target.takeDamage(self.damage); LK.getSound('shoot').play(); LK.getSound('hit').play(); // Recoil animation tween(towerGraphics, { scaleX: originalScaleX * 0.8, scaleY: 0.8 }, { duration: 100, onFinish: function onFinish() { tween(towerGraphics, { scaleX: originalScaleX, scaleY: 1 }, { duration: 100 }); } }); }; self.getSellPrice = function () { return Math.floor(self.cost * 0.7); // 70% of original cost }; // Removed down handler - sell UI is now only shown via dedicated sell button or long press return self; }); /**** * Initialize Game ****/ // Game state variables var game = new LK.Game({ backgroundColor: 0x228B22 }); /**** * Game Code ****/ // Game state variables // Import tween plugin for animations // Game assets var mice = []; var rats = []; var towers = []; var gameGold = 200; var packetHealth = 100; var waveNumber = 1; var miceSpawned = 0; var ratsSpawned = 0; var maxMicePerWave = 5; var maxRatsPerWave = 0; var spawnTimer = 0; var ratSpawnTimer = 0; var spawnRate = 90; // frames between spawns (reduced from 120) var ratSpawnRate = 140; // frames between rat spawns (reduced from 180) var gameStarted = false; var gameStartTimer = 0; var isPaused = false; var pauseTimer = 0; var pauseText = null; // Create path for mice - random zigzag movement var gamePath = [{ x: 1024, y: 50 }, { x: 600, y: 300 }, { x: 1400, y: 600 }, { x: 400, y: 900 }, { x: 1600, y: 1200 }, { x: 800, y: 1500 }, { x: 1200, y: 1800 }, { x: 500, y: 2100 }, { x: 1500, y: 2400 }, { x: 1024, y: 2700 }]; // Path is now invisible - no visual squares // Create packet of treats at the end var packet = game.addChild(LK.getAsset('packetTreats', { anchorX: 0.5, anchorY: 0.5 })); packet.x = gamePath[gamePath.length - 1].x; packet.y = gamePath[gamePath.length - 1].y - 200; // Create placement grid (invisible spots without visual squares) var placementSpots = []; for (var x = 100; x < 1950; x += 200) { for (var y = 150; y < 2600; y += 200) { var isOnPath = false; for (var p = 0; p < gamePath.length; p++) { if (Math.abs(gamePath[p].x - x) < 150 && Math.abs(gamePath[p].y - y) < 150) { isOnPath = true; break; } } if (!isOnPath) { var spot = new Container(); spot.x = x; spot.y = y; spot.gridX = x; spot.gridY = y; spot.occupied = false; game.addChild(spot); placementSpots.push(spot); } } } // UI Elements var goldText = new Text2('Gold: ' + gameGold, { size: 60, fill: 0xFFD700 }); goldText.anchor.set(0, 0); goldText.x = 50; goldText.y = 50; LK.gui.topLeft.addChild(goldText); var healthText = new Text2('Packet Health: ' + packetHealth, { size: 60, fill: 0xFF0000 }); healthText.anchor.set(0.5, 0); healthText.x = 0; healthText.y = 50; LK.gui.top.addChild(healthText); var waveText = new Text2('Wave: ' + waveNumber, { size: 60, fill: 0xFFFFFF }); waveText.anchor.set(1, 0); waveText.x = 0; waveText.y = 50; LK.gui.topRight.addChild(waveText); // Create start button square var startButton = LK.getAsset('startButton', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); startButton.x = 0; startButton.y = 0; startButton.interactive = false; LK.gui.center.addChild(startButton); // Add tutorial images to start button var tutorialCat = LK.getAsset('tiredCat', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8, alpha: 0 }); tutorialCat.x = -120; tutorialCat.y = -20; startButton.addChild(tutorialCat); // Add arrow pointing from cat to mouse var arrow = new Text2('→', { size: 60, fill: 0xFFFFFF }); arrow.anchor.set(0.5, 0.5); arrow.x = 0; arrow.y = -20; arrow.alpha = 0; startButton.addChild(arrow); // Add mouse image var tutorialMouse = LK.getAsset('mouse', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6, alpha: 0 }); tutorialMouse.x = 120; tutorialMouse.y = -20; startButton.addChild(tutorialMouse); // Add click handler to start button startButton.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; // Hide start button immediately startButton.alpha = 0; startButton.interactive = false; // Hide tutorial images tutorialCat.alpha = 0; arrow.alpha = 0; tutorialMouse.alpha = 0; } }; // Show start button after 10 seconds LK.setTimeout(function () { if (!gameStarted) { tween(startButton, { alpha: 1 }, { duration: 500 }); // Show tutorial images tween(tutorialCat, { alpha: 1 }, { duration: 500 }); tween(arrow, { alpha: 1 }, { duration: 500 }); tween(tutorialMouse, { alpha: 1 }, { duration: 500 }); startButton.interactive = true; } }, 10000); // Tower selection UI var selectedTowerType = 'normal'; // No menu background - cleaner UI // Create tired cat button with asset var tiredCatButton = LK.getAsset('tiredCat', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); tiredCatButton.x = -200; tiredCatButton.y = -80; LK.gui.bottom.addChild(tiredCatButton); // Create price text for tired cat var tiredCatPrice = new Text2('50g', { size: 40, fill: 0xFFD700 }); tiredCatPrice.anchor.set(0.5, 0); tiredCatPrice.x = -200; tiredCatPrice.y = -40; LK.gui.bottom.addChild(tiredCatPrice); // Add instruction text var instructionText = new Text2('Drag cats to place them!', { size: 30, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 1); instructionText.x = 0; instructionText.y = -140; LK.gui.bottom.addChild(instructionText); // Create normal cat button with asset var normalCatButton = LK.getAsset('normalCat', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.6, scaleY: 0.6 }); normalCatButton.x = 200; normalCatButton.y = -80; LK.gui.bottom.addChild(normalCatButton); // Create price text for normal cat var normalCatPrice = new Text2('250g', { size: 40, fill: 0xFFD700 }); normalCatPrice.anchor.set(0.5, 0); normalCatPrice.x = 200; normalCatPrice.y = -40; LK.gui.bottom.addChild(normalCatPrice); // Create wild cat button with asset var wildCatButton = LK.getAsset('wildCat', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.7, scaleY: 0.7 }); wildCatButton.x = 400; wildCatButton.y = -80; LK.gui.bottom.addChild(wildCatButton); // Create price text for wild cat var wildCatPrice = new Text2('300g', { size: 40, fill: 0xFFD700 }); wildCatPrice.anchor.set(0.5, 0); wildCatPrice.x = 400; wildCatPrice.y = -40; LK.gui.bottom.addChild(wildCatPrice); // Create tiger button with asset var tigerButton = LK.getAsset('tiger', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.5, scaleY: 0.5 }); tigerButton.x = 600; tigerButton.y = -80; LK.gui.bottom.addChild(tigerButton); // Create price text for tiger var tigerPrice = new Text2('500g', { size: 40, fill: 0xFFD700 }); tigerPrice.anchor.set(0.5, 0); tigerPrice.x = 600; tigerPrice.y = -40; LK.gui.bottom.addChild(tigerPrice); // Initialize button transparency updateTiredCatButtonAlpha(); updateNormalCatButtonAlpha(); updateWildCatButtonAlpha(); updateTigerButtonAlpha(); // Dragging variables var isDragging = false; var draggedTower = null; var dragOffset = { x: 0, y: 0 }; // Sell UI variables var sellUI = null; var sellUITower = null; function updateGoldDisplay() { goldText.setText('Gold: ' + gameGold); updateTiredCatButtonAlpha(); updateNormalCatButtonAlpha(); updateWildCatButtonAlpha(); updateTigerButtonAlpha(); } function updatePacketDisplay() { healthText.setText('Packet Health: ' + packetHealth); } function updateWaveDisplay() { waveText.setText('Wave: ' + waveNumber); } function showSellUI(tower) { // Remove existing sell UI if (sellUI) { sellUI.destroy(); sellUI = null; } sellUITower = tower; sellUI = new Container(); game.addChild(sellUI); // Position sell UI above tower sellUI.x = tower.x; sellUI.y = tower.y - 100; // Create sell button var sellButton = sellUI.attachAsset('sellButton', { anchorX: 0.5, anchorY: 0.5 }); // Create sell price text var sellPrice = tower.getSellPrice(); var sellText = new Text2('SELL\n' + sellPrice + 'g', { size: 24, fill: 0xFFFFFF }); sellText.anchor.set(0.5, 0.5); sellText.x = 0; sellText.y = 0; sellUI.addChild(sellText); // Sell button click handler sellButton.down = function (x, y, obj) { sellTower(sellUITower); }; // Auto-hide sell UI after 3 seconds LK.setTimeout(function () { if (sellUI) { sellUI.destroy(); sellUI = null; sellUITower = null; } }, 3000); } function sellTower(tower) { // Give back gold (70% of original cost) var sellPrice = tower.getSellPrice(); gameGold += sellPrice; updateGoldDisplay(); LK.getSound('mouseHit').play(); // Find and free the placement spot for (var i = 0; i < placementSpots.length; i++) { var spot = placementSpots[i]; var distance = Math.sqrt(Math.pow(spot.x - tower.x, 2) + Math.pow(spot.y - tower.y, 2)); if (distance < 10) { spot.occupied = false; spot.alpha = 0.3; break; } } // Remove tower from towers array var towerIndex = towers.indexOf(tower); if (towerIndex > -1) { towers.splice(towerIndex, 1); } // Destroy tower tower.destroy(); // Hide sell UI if (sellUI) { sellUI.destroy(); sellUI = null; sellUITower = null; } } // Tired cat button drag functionality tiredCatButton.down = function (x, y, obj) { if (gameGold >= 50) { // Hide sell UI when starting to drag if (sellUI) { sellUI.destroy(); sellUI = null; sellUITower = null; } isDragging = true; selectedTowerType = 'tired'; // Create dragged tower preview draggedTower = new Tower('tired'); draggedTower.alpha = 0.8; draggedTower.scaleX = 1.2; draggedTower.scaleY = 1.2; game.addChild(draggedTower); // Convert button position to game coordinates var buttonWorldPos = game.toLocal(tiredCatButton.parent.toGlobal(tiredCatButton.position)); draggedTower.x = buttonWorldPos.x; draggedTower.y = buttonWorldPos.y; dragOffset.x = x; dragOffset.y = y; // Button feedback tween(tiredCatButton, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, onFinish: function onFinish() { tween(tiredCatButton, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100 }); } }); } }; function updateTiredCatButtonAlpha() { if (gameGold >= 50) { tiredCatButton.alpha = 1; tiredCatPrice.alpha = 1; tiredCatButton.interactive = true; } else { tiredCatButton.alpha = 0.5; tiredCatPrice.alpha = 0.5; tiredCatButton.interactive = false; } } // Normal cat button drag functionality normalCatButton.down = function (x, y, obj) { if (gameGold >= 250) { // Hide sell UI when starting to drag if (sellUI) { sellUI.destroy(); sellUI = null; sellUITower = null; } isDragging = true; selectedTowerType = 'normal'; // Create dragged tower preview draggedTower = new Tower('normal'); draggedTower.alpha = 0.8; draggedTower.scaleX = 1.2; draggedTower.scaleY = 1.2; game.addChild(draggedTower); // Convert button position to game coordinates var buttonWorldPos = game.toLocal(normalCatButton.parent.toGlobal(normalCatButton.position)); draggedTower.x = buttonWorldPos.x; draggedTower.y = buttonWorldPos.y; dragOffset.x = x; dragOffset.y = y; // Button feedback tween(normalCatButton, { scaleX: 0.7, scaleY: 0.7 }, { duration: 100, onFinish: function onFinish() { tween(normalCatButton, { scaleX: 0.6, scaleY: 0.6 }, { duration: 100 }); } }); } }; function updateNormalCatButtonAlpha() { if (gameGold >= 250) { normalCatButton.alpha = 1; normalCatPrice.alpha = 1; normalCatButton.interactive = true; } else { normalCatButton.alpha = 0.5; normalCatPrice.alpha = 0.5; normalCatButton.interactive = false; } } // Wild cat button drag functionality wildCatButton.down = function (x, y, obj) { if (gameGold >= 300) { // Hide sell UI when starting to drag if (sellUI) { sellUI.destroy(); sellUI = null; sellUITower = null; } isDragging = true; selectedTowerType = 'wild'; // Create dragged tower preview draggedTower = new Tower('wild'); draggedTower.alpha = 0.8; draggedTower.scaleX = 1.2; draggedTower.scaleY = 1.2; game.addChild(draggedTower); // Convert button position to game coordinates var buttonWorldPos = game.toLocal(wildCatButton.parent.toGlobal(wildCatButton.position)); draggedTower.x = buttonWorldPos.x; draggedTower.y = buttonWorldPos.y; dragOffset.x = x; dragOffset.y = y; // Button feedback tween(wildCatButton, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100, onFinish: function onFinish() { tween(wildCatButton, { scaleX: 0.7, scaleY: 0.7 }, { duration: 100 }); } }); } }; function updateWildCatButtonAlpha() { if (gameGold >= 300) { wildCatButton.alpha = 1; wildCatPrice.alpha = 1; wildCatButton.interactive = true; } else { wildCatButton.alpha = 0.5; wildCatPrice.alpha = 0.5; wildCatButton.interactive = false; } } // Tiger button drag functionality tigerButton.down = function (x, y, obj) { if (gameGold >= 500) { // Hide sell UI when starting to drag if (sellUI) { sellUI.destroy(); sellUI = null; sellUITower = null; } isDragging = true; selectedTowerType = 'tiger'; // Create dragged tower preview draggedTower = new Tower('tiger'); draggedTower.alpha = 0.8; draggedTower.scaleX = 1.2; draggedTower.scaleY = 1.2; game.addChild(draggedTower); // Convert button position to game coordinates var buttonWorldPos = game.toLocal(tigerButton.parent.toGlobal(tigerButton.position)); draggedTower.x = buttonWorldPos.x; draggedTower.y = buttonWorldPos.y; dragOffset.x = x; dragOffset.y = y; // Button feedback tween(tigerButton, { scaleX: 0.6, scaleY: 0.6 }, { duration: 100, onFinish: function onFinish() { tween(tigerButton, { scaleX: 0.5, scaleY: 0.5 }, { duration: 100 }); } }); } }; function updateTigerButtonAlpha() { if (gameGold >= 500) { tigerButton.alpha = 1; tigerPrice.alpha = 1; tigerButton.interactive = true; } else { tigerButton.alpha = 0.5; tigerPrice.alpha = 0.5; tigerButton.interactive = false; } } // Game move handler for dragging game.move = function (x, y, obj) { if (isDragging && draggedTower) { draggedTower.x = x; draggedTower.y = y; // Highlight closest valid placement spot var closestSpot = null; var closestDistance = Infinity; for (var i = 0; i < placementSpots.length; i++) { var spot = placementSpots[i]; var distance = Math.sqrt(Math.pow(spot.x - x, 2) + Math.pow(spot.y - y, 2)); if (distance < closestDistance && distance < 150 && !spot.occupied) { closestDistance = distance; closestSpot = spot; } } // Visual feedback through tower tint only if (closestSpot) { draggedTower.tint = 0x00ff00; // Green tint for valid placement } else { draggedTower.tint = 0xff0000; // Red tint for invalid placement } } }; // Game up handler for tower placement game.up = function (x, y, obj) { if (isDragging && draggedTower) { var closestSpot = null; var closestDistance = Infinity; for (var i = 0; i < placementSpots.length; i++) { var spot = placementSpots[i]; var distance = Math.sqrt(Math.pow(spot.x - x, 2) + Math.pow(spot.y - y, 2)); if (distance < closestDistance && distance < 150 && !spot.occupied) { closestDistance = distance; closestSpot = spot; } } var towerCost = draggedTower.cost; if (closestSpot && gameGold >= towerCost) { // Place tower gameGold -= towerCost; updateGoldDisplay(); draggedTower.x = closestSpot.x; draggedTower.y = closestSpot.y; draggedTower.alpha = 1; draggedTower.scaleX = 1; draggedTower.scaleY = 1; draggedTower.tint = 0xffffff; // Reset tint towers.push(draggedTower); closestSpot.occupied = true; LK.getSound('shoot').play(); } else { // Remove dragged tower if placement failed draggedTower.destroy(); } // No visual grid to reset // Reset dragging state isDragging = false; draggedTower = null; } else if (!isDragging) { // Check if clicked on a tower to show sell UI for (var i = 0; i < towers.length; i++) { var tower = towers[i]; var distance = Math.sqrt(Math.pow(tower.x - x, 2) + Math.pow(tower.y - y, 2)); if (distance < 50) { showSellUI(tower); break; } } } }; // Start background music LK.playMusic('bgMusic'); game.update = function () { // Don't spawn mice until game starts (start button clicked) if (!gameStarted) { return; // Don't spawn mice until game starts } // Handle pause after wave 3 if (isPaused) { pauseTimer++; if (pauseTimer >= 600) { // 10 seconds at 60fps isPaused = false; // Remove pause text if (pauseText) { pauseText.destroy(); pauseText = null; } // Show wave start text var waveStartText = new Text2('Wave ' + waveNumber + ' - START!', { size: 80, fill: 0xFFFF00 }); waveStartText.anchor.set(0.5, 0.5); waveStartText.x = 0; waveStartText.y = 0; LK.gui.center.addChild(waveStartText); tween(waveStartText, { alpha: 0 }, { duration: 2000, onFinish: function onFinish() { waveStartText.destroy(); } }); } return; // Don't spawn enemies during pause } // Spawn mice spawnTimer++; if (spawnTimer >= spawnRate && miceSpawned < maxMicePerWave) { var mouse = new Mouse(); mouse.x = gamePath[0].x + (Math.random() - 0.5) * 200; mouse.y = gamePath[0].y + (Math.random() - 0.5) * 100; mouse.health = 150 + waveNumber * 40; // Increased base health and scaling mouse.maxHealth = mouse.health; mouse.speed = mouse.speed * 1.3; // Make mice 30% faster mouse.updateHealthBar(); mice.push(mouse); game.addChild(mouse); miceSpawned++; spawnTimer = 0; } // Spawn rats (only after wave 3) if (waveNumber > 3) { ratSpawnTimer++; if (ratSpawnTimer >= ratSpawnRate && ratsSpawned < maxRatsPerWave) { var rat = new Rat(); rat.x = gamePath[0].x + (Math.random() - 0.5) * 200; rat.y = gamePath[0].y + (Math.random() - 0.5) * 100; rat.health = 300 + waveNumber * 75; // Increased base health and scaling rat.maxHealth = rat.health; rat.speed = rat.speed * 1.4; // Make rats 40% faster rat.updateHealthBar(); rats.push(rat); game.addChild(rat); ratsSpawned++; ratSpawnTimer = 0; } } // Check if wave is complete if (miceSpawned >= maxMicePerWave && ratsSpawned >= maxRatsPerWave && mice.length === 0 && rats.length === 0) { // Check if wave 3 just completed if (waveNumber === 3) { isPaused = true; pauseTimer = 0; // Create pause text pauseText = new Text2('Rats incoming in 10 seconds!', { size: 80, fill: 0xFFFF00 }); pauseText.anchor.set(0.5, 0.5); pauseText.x = 0; pauseText.y = 0; LK.gui.center.addChild(pauseText); // Flash effect tween(pauseText, { alpha: 0.3 }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { tween(pauseText, { alpha: 1 }, { duration: 500, easing: tween.easeInOut }); } }); } waveNumber++; miceSpawned = 0; ratsSpawned = 0; maxMicePerWave += 2; // Start spawning rats after wave 3 if (waveNumber > 3) { maxRatsPerWave = Math.max(1, waveNumber - 3); } spawnRate = Math.max(45, spawnRate - 8); // Faster decrease, lower minimum ratSpawnRate = Math.max(90, ratSpawnRate - 15); // Faster decrease, lower minimum updateWaveDisplay(); } // Update all game objects for (var i = mice.length - 1; i >= 0; i--) { if (mice[i].parent) { mice[i].update(); } } for (var i = rats.length - 1; i >= 0; i--) { if (rats[i].parent) { rats[i].update(); } } for (var i = towers.length - 1; i >= 0; i--) { if (towers[i].parent) { towers[i].update(); } } };
===================================================================
--- original.js
+++ change.js
@@ -377,26 +377,17 @@
}, {
x: 1024,
y: 2700
}];
-// Draw path
-for (var i = 0; i < gamePath.length; i++) {
- var pathSegment = game.addChild(LK.getAsset('path', {
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.5
- }));
- pathSegment.x = gamePath[i].x;
- pathSegment.y = gamePath[i].y;
-}
+// Path is now invisible - no visual squares
// Create packet of treats at the end
var packet = game.addChild(LK.getAsset('packetTreats', {
anchorX: 0.5,
anchorY: 0.5
}));
packet.x = gamePath[gamePath.length - 1].x;
packet.y = gamePath[gamePath.length - 1].y - 200;
-// Create placement grid
+// Create placement grid (invisible spots without visual squares)
var placementSpots = [];
for (var x = 100; x < 1950; x += 200) {
for (var y = 150; y < 2600; y += 200) {
var isOnPath = false;
@@ -406,18 +397,15 @@
break;
}
}
if (!isOnPath) {
- var spot = game.addChild(LK.getAsset('placementGrid', {
- anchorX: 0.5,
- anchorY: 0.5,
- alpha: 0.3
- }));
+ var spot = new Container();
spot.x = x;
spot.y = y;
spot.gridX = x;
spot.gridY = y;
spot.occupied = false;
+ game.addChild(spot);
placementSpots.push(spot);
}
}
}
@@ -529,19 +517,9 @@
}
}, 10000);
// Tower selection UI
var selectedTowerType = 'normal';
-// Create bottom menu background
-var menuBackground = LK.getAsset('placementGrid', {
- anchorX: 0.5,
- anchorY: 1,
- scaleX: 20,
- scaleY: 2,
- alpha: 0.8
-});
-menuBackground.x = 0;
-menuBackground.y = 0;
-LK.gui.bottom.addChild(menuBackground);
+// No menu background - cleaner UI
// Create tired cat button with asset
var tiredCatButton = LK.getAsset('tiredCat', {
anchorX: 0.5,
anchorY: 0.5,
@@ -943,17 +921,10 @@
closestDistance = distance;
closestSpot = spot;
}
}
- // Reset all spot alphas
- for (var i = 0; i < placementSpots.length; i++) {
- if (!placementSpots[i].occupied) {
- placementSpots[i].alpha = 0.3;
- }
- }
- // Highlight closest spot
+ // Visual feedback through tower tint only
if (closestSpot) {
- closestSpot.alpha = 0.8;
draggedTower.tint = 0x00ff00; // Green tint for valid placement
} else {
draggedTower.tint = 0xff0000; // Red tint for invalid placement
}
@@ -984,20 +955,14 @@
draggedTower.scaleY = 1;
draggedTower.tint = 0xffffff; // Reset tint
towers.push(draggedTower);
closestSpot.occupied = true;
- closestSpot.alpha = 0.1;
LK.getSound('shoot').play();
} else {
// Remove dragged tower if placement failed
draggedTower.destroy();
}
- // Reset all spot alphas
- for (var i = 0; i < placementSpots.length; i++) {
- if (!placementSpots[i].occupied) {
- placementSpots[i].alpha = 0.3;
- }
- }
+ // No visual grid to reset
// Reset dragging state
isDragging = false;
draggedTower = null;
} else if (!isDragging) {
Un emignone souris cartoon style sur ses quatres pattes. In-Game asset. 2d. High contrast. No shadows
Cute tired cat manga cartoon style. In-Game asset. 2d. High contrast. No shadows
A cute manga style cat. In-Game asset. 2d. High contrast. No shadows
An angry but cute wild cat manga cartoon style. In-Game asset. 2d. High contrast. No shadows
A big angry cute tiger. In-Game asset. 2d. High contrast. No shadows
A pretty air view grass plain. In-Game asset. 2d. High contrast. No shadows
A red rectangular button. In-Game asset. 2d. High contrast. No shadows
A cute hare running on 4 paws. In-Game asset. 2d. High contrast. No shadows
cute lil bird flying cartoon style
Make more manga style and cutter with cut colors
a cute angry dog manga style. In-Game asset. 2d. High contrast. No shadows