User prompt
Make predators increase every level start with just water rats in level one, then add snakes in level two then add goannas in level 3
User prompt
Please fix the bug: 'Timeout.tick error: bill is not defined' in or related to this line: 'bill.alpha = 1;' Line Number: 146
User prompt
Please fix the bug: 'Timeout.tick error: bill is not defined' in or related to this line: 'bill.alpha = bill.alpha === 1 ? 0.3 : 1;' Line Number: 141
User prompt
Remove bill
User prompt
Remove one hiding spot every level up
User prompt
Make it that every level up predators get faster
User prompt
Make the level system so it levels up every 100 points
User prompt
Make a level system eat 20 food for level 2, 40 food for level 3, 60 food level 4 etc
User prompt
Don't show high score during gameplay
User prompt
Make a high score list ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Remove ripple effect
User prompt
Add ripples and splashes in water
User prompt
Allow platypus to face different directions
User prompt
Stop platypus being backwards
User prompt
Stop platypus being upside down
User prompt
Please remove fox from predators
Code edit (1 edits merged)
Please save this source code
User prompt
Platypus Pond: Survival Splash
Initial prompt
Hi Ava , I'd like to make a game where you play as a platypus swimming around a big lake in Australia. To survive you must find insects and shrimp to eat and avoid predators such as snakes, water rats, goannas and foxes.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScores: [] }); /**** * Classes ****/ var Food = Container.expand(function (type) { var self = Container.call(this); self.type = type || 'insect'; self.value = self.type === 'insect' ? 5 : 10; // Shrimp gives more energy var graphic = self.attachAsset(self.type, { anchorX: 0.5, anchorY: 0.5 }); // Random movement self.speedX = (Math.random() - 0.5) * 2; self.speedY = (Math.random() - 0.5) * 2; self.update = function () { self.x += self.speedX; self.y += self.speedY; // Bounce off edges if (self.x < 50 || self.x > 2048 - 50) { self.speedX *= -1; } if (self.y < 50 || self.y > 2732 - 50) { self.speedY *= -1; } }; return self; }); var HideSpot = Container.expand(function () { var self = Container.call(this); var graphic = self.attachAsset('hideSpot', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); return self; }); var Platypus = Container.expand(function () { var self = Container.call(this); // Create platypus body var body = self.attachAsset('platypus', { anchorX: 0.5, anchorY: 0.5 }); // Platypus properties self.speed = 8; self.energy = 100; self.maxEnergy = 100; self.hidden = false; self.invulnerable = false; // Movement target for smooth motion self.targetX = 0; self.targetY = 0; self.update = function () { // Move towards target position smoothly if (Math.abs(self.x - self.targetX) > 5 || Math.abs(self.y - self.targetY) > 5) { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var angle = Math.atan2(dy, dx); self.x += Math.cos(angle) * self.speed; self.y += Math.sin(angle) * self.speed; // Rotate platypus to face movement direction self.rotation = angle; } // Decrease energy over time if (LK.ticks % 60 === 0 && !self.hidden) { self.energy -= 1; if (self.energy <= 0) { self.energy = 0; // Update high score list var highScores = storage.highScores; highScores.push(score); highScores.sort(function (a, b) { return b - a; }); if (highScores.length > 5) { highScores.pop(); // Keep only top 5 scores } storage.highScores = highScores; LK.showGameOver(); } } }; self.hide = function () { if (!self.hidden) { self.hidden = true; LK.getSound('hide').play(); tween(self, { alpha: 0.3 }, { duration: 300 }); } }; self.unhide = function () { if (self.hidden) { self.hidden = true; tween(self, { alpha: 1 }, { duration: 300, onFinish: function onFinish() { self.hidden = false; } }); } }; self.makeInvulnerable = function (duration) { self.invulnerable = true; // Flash effect to show invulnerability var flashCount = 0; var flashInterval = LK.setInterval(function () { body.alpha = body.alpha === 1 ? 0.3 : 1; // Removed reference to undefined 'bill' flashCount++; if (flashCount >= 10) { LK.clearInterval(flashInterval); body.alpha = 1; self.invulnerable = false; } }, 150); }; self.takeDamage = function (amount) { if (!self.invulnerable && !self.hidden) { self.energy -= amount; LK.getSound('damage').play(); LK.effects.flashScreen(0xFF0000, 300); if (self.energy <= 0) { self.energy = 0; LK.showGameOver(); } else { self.makeInvulnerable(1500); } } }; return self; }); var Predator = Container.expand(function (type) { var self = Container.call(this); self.type = type || 'snake'; // Different predators have different damage and speed switch (self.type) { case 'snake': self.damage = 20; self.moveSpeed = 3; break; case 'waterRat': self.damage = 15; self.moveSpeed = 4; break; case 'goanna': self.damage = 25; self.moveSpeed = 2.5; break; default: self.damage = 15; self.moveSpeed = 3; } var graphic = self.attachAsset(self.type, { anchorX: 0.5, anchorY: 0.5 }); // Target positions for movement self.targetX = 0; self.targetY = 0; self.active = true; self.update = function () { if (self.active) { // Move towards target var dx = self.targetX - self.x; var dy = self.targetY - self.y; var angle = Math.atan2(dy, dx); self.x += Math.cos(angle) * self.moveSpeed; self.y += Math.sin(angle) * self.moveSpeed; // Rotate to face movement direction self.rotation = angle; // Change direction occasionally or if close to target if (LK.ticks % 120 === 0 || Math.abs(dx) < 20 && Math.abs(dy) < 20) { self.pickNewTarget(); } } }; self.pickNewTarget = function () { self.targetX = 100 + Math.random() * (2048 - 200); self.targetY = 100 + Math.random() * (2732 - 200); }; // Initial target self.pickNewTarget(); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x4DA6FF }); /**** * Game Code ****/ var background = LK.getAsset('waterBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChild(background); // Game variables var score = 0; var level = 1; var foodEaten = 0; var foodItems = []; var predators = []; var hideSpots = []; var gameStarted = false; var spawnInterval = null; var predatorInterval = null; var dragNode = null; // Create platypus var platypus = new Platypus(); platypus.x = 2048 / 2; platypus.y = 2732 / 2; game.addChild(platypus); // Create hide spots function createHideSpots() { // Create 5 hide spots around the pond for (var i = 0; i < 5; i++) { var hideSpot = new HideSpot(); hideSpot.x = 300 + Math.random() * (2048 - 600); hideSpot.y = 300 + Math.random() * (2732 - 600); game.addChild(hideSpot); hideSpots.push(hideSpot); } } // Create UI var scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 60; // Energy bar background var energyBarBg = LK.getAsset('energyBarBg', { anchorX: 0.5, anchorY: 0.5 }); LK.gui.bottom.addChild(energyBarBg); energyBarBg.y = -100; // Energy bar var energyBar = LK.getAsset('energyBar', { anchorX: 0, anchorY: 0.5, x: -250, y: 0 }); energyBarBg.addChild(energyBar); // Instructions text var instructionsTxt = new Text2('Tap to guide your platypus. Catch food and avoid predators!', { size: 40, fill: 0xFFFFFF }); instructionsTxt.anchor.set(0.5, 0.5); LK.gui.center.addChild(instructionsTxt); // Start game function function startGame() { if (!gameStarted) { gameStarted = true; createHideSpots(); // Remove instructions instructionsTxt.destroy(); // Schedule food spawning spawnInterval = LK.setInterval(function () { spawnFood(); }, 2000); // Schedule predator spawning predatorInterval = LK.setInterval(function () { spawnPredator(); }, 5000); // Play background music LK.playMusic('gameMusic'); } } // Spawn food function spawnFood() { var foodType = Math.random() < 0.7 ? 'insect' : 'shrimp'; var food = new Food(foodType); // Spawn food at random positions, but not too close to the edges food.x = 100 + Math.random() * (2048 - 200); food.y = 100 + Math.random() * (2732 - 200); game.addChild(food); foodItems.push(food); // Food automatically disappears after some time LK.setTimeout(function () { if (foodItems.indexOf(food) !== -1) { foodItems.splice(foodItems.indexOf(food), 1); food.destroy(); } }, 10000); } // Spawn predator function spawnPredator() { // Don't spawn too many predators if (predators.length >= 5) { return; } // Choose predator type based on the current level var types = []; if (level >= 1) { types.push('waterRat'); } if (level >= 2) { types.push('snake'); } if (level >= 3) { types.push('goanna'); } var randomType = types[Math.floor(Math.random() * types.length)]; var predator = new Predator(randomType); // Spawn predator at edge of screen var side = Math.floor(Math.random() * 4); switch (side) { case 0: // Top predator.x = Math.random() * 2048; predator.y = -50; break; case 1: // Right predator.x = 2048 + 50; predator.y = Math.random() * 2732; break; case 2: // Bottom predator.x = Math.random() * 2048; predator.y = 2732 + 50; break; case 3: // Left predator.x = -50; predator.y = Math.random() * 2732; break; } game.addChild(predator); predators.push(predator); // Predator leaves after some time LK.setTimeout(function () { if (predators.indexOf(predator) !== -1) { predators.splice(predators.indexOf(predator), 1); predator.destroy(); } }, 15000 + Math.random() * 10000); } // Check if platypus is in a hide spot function checkHideSpots() { var inHideSpot = false; for (var i = 0; i < hideSpots.length; i++) { if (platypus.intersects(hideSpots[i])) { inHideSpot = true; if (!platypus.hidden) { platypus.hide(); } break; } } if (!inHideSpot && platypus.hidden) { platypus.unhide(); } } // Handle game input function handleMove(x, y, obj) { if (dragNode) { dragNode.targetX = x; dragNode.targetY = y; } } game.move = handleMove; game.down = function (x, y, obj) { if (!gameStarted) { startGame(); } dragNode = platypus; platypus.targetX = x; platypus.targetY = y; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; // Main game update game.update = function () { // Update energy bar energyBar.width = platypus.energy / platypus.maxEnergy * 500; // Check if platypus is in a hide spot checkHideSpots(); // Check for food collisions for (var i = foodItems.length - 1; i >= 0; i--) { if (platypus.intersects(foodItems[i])) { // Eat food var food = foodItems[i]; platypus.energy = Math.min(platypus.maxEnergy, platypus.energy + food.value); score += food.value; foodEaten += 1; if (score >= level * 100) { level += 1; console.log("Level Up! Current Level: " + level); // Increase predator speed with each level up predators.forEach(function (predator) { predator.moveSpeed += 0.5; // Increase speed by 0.5 for each level }); // Remove one hiding spot every level up if (hideSpots.length > 0) { var removedHideSpot = hideSpots.pop(); removedHideSpot.destroy(); } } scoreTxt.setText("Score: " + score + " | Level: " + level); // Remove food foodItems.splice(i, 1); food.destroy(); // Create splash effect var splash = LK.getAsset('splash', { anchorX: 0.5, anchorY: 0.5, x: food.x, y: food.y, alpha: 0.7 }); game.addChild(splash); tween(splash, { alpha: 0 }, { duration: 800, onFinish: function onFinish() { splash.destroy(); } }); // Play eat sound LK.getSound('eat').play(); } } // Check for predator collisions for (var j = 0; j < predators.length; j++) { var predator = predators[j]; // Predator follows platypus if not hidden if (!platypus.hidden && LK.ticks % 60 === 0) { var chaseChance = 0.7; if (Math.random() < chaseChance) { predator.targetX = platypus.x; predator.targetY = platypus.y; } } // Check collision with platypus if (platypus.intersects(predator) && !platypus.hidden) { platypus.takeDamage(predator.damage); // Push predator away from platypus var pushAngle = Math.atan2(predator.y - platypus.y, predator.x - platypus.x); predator.x += Math.cos(pushAngle) * 150; predator.y += Math.sin(pushAngle) * 150; predator.pickNewTarget(); } } // Spawn initial food if game has started if (gameStarted && foodItems.length === 0 && LK.ticks === 10) { for (var k = 0; k < 3; k++) { spawnFood(); } } };
===================================================================
--- original.js
+++ change.js
@@ -311,10 +311,19 @@
// Don't spawn too many predators
if (predators.length >= 5) {
return;
}
- // Choose random predator type
- var types = ['snake', 'waterRat', 'goanna'];
+ // Choose predator type based on the current level
+ var types = [];
+ if (level >= 1) {
+ types.push('waterRat');
+ }
+ if (level >= 2) {
+ types.push('snake');
+ }
+ if (level >= 3) {
+ types.push('goanna');
+ }
var randomType = types[Math.floor(Math.random() * types.length)];
var predator = new Predator(randomType);
// Spawn predator at edge of screen
var side = Math.floor(Math.random() * 4);
Cute Platypus swimming. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. In game asset main character 2d
Dragonfly, small but detailed. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Green reeds with Lilly pad. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Light Brown moving snake top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Goanna swimming top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Pink shrimp. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Water rat swimming top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Small splash in water. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Green water energy bar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows