User prompt
let the fruits accelerate more slowly
User prompt
add background
User prompt
Let the score start at 1 and if we drop to 0, we lose.
User prompt
balls and fruits come faster as the game progresses and bad balls score more as the game progresses. no end game
User prompt
5 farklı top daha ekle
User prompt
mixed with flat and sloping
User prompt
not straight, but sloping or hitting the edges
User prompt
Please fix the bug: 'updateTimerText is not defined' in or related to this line: 'updateTimerText();' Line Number: 199
User prompt
no second limit and more different colored balls
Code edit (1 edits merged)
Please save this source code
User prompt
Apple Basket AI
Initial prompt
The player moves a basket left and right. Apples fall from the top. But sometimes rotten apples also fall. The player's aim is to fill the basket only with good apples. If he touches a rotten apple, he loses points. The AI can recognize whether the apple is good or bad and makes a random decision
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Apple class: can be good or bad, and have different colors var Apple = Container.expand(function () { var self = Container.call(this); // Randomly decide if this apple is good or bad self.isGood = Math.random() < 0.7; // 70% good, 30% bad // Pick a random color for good and bad apples var goodAppleTypes = ['goodApple', 'goodAppleGreen', 'goodAppleYellow', 'goodAppleBlue', 'goodApplePurple']; var badAppleTypes = ['badApple', 'badApplePurple', 'badAppleBlue', 'badAppleOrange', 'badApplePink']; var assetId; if (self.isGood) { assetId = goodAppleTypes[Math.floor(Math.random() * goodAppleTypes.length)]; } else { assetId = badAppleTypes[Math.floor(Math.random() * badAppleTypes.length)]; } // Attach correct asset var appleAsset = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Set falling speed (randomize a bit) self.speed = 12 + Math.random() * 6; // Mix: 50% apples fall straight, 50% sloped and bounce if (Math.random() < 0.5) { // Flat: straight down self.xSpeed = 0; } else { // Sloping: random left/right, random speed self.xSpeed = (Math.random() < 0.5 ? -1 : 1) * (6 + Math.random() * 8); } // For edge bounce, need to know lastX self.lastX = self.x; // For intersection tracking self.lastIntersecting = false; // Update method called every tick self.update = function () { // Save lastX for edge bounce detection self.lastX = self.x; self.y += self.speed; self.x += self.xSpeed; // Bounce off left edge if (self.lastX >= 60 && self.x < 60) { self.x = 60; self.xSpeed *= -1; } // Bounce off right edge if (self.lastX <= GAME_WIDTH - 60 && self.x > GAME_WIDTH - 60) { self.x = GAME_WIDTH - 60; self.xSpeed *= -1; } }; return self; }); // Basket class var Basket = Container.expand(function () { var self = Container.call(this); var basketAsset = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5 }); // Optionally, add a little "lip" to the basket for visual // (not required for MVP) // No update needed for basket return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // Sky blue }); /**** * Game Code ****/ // Music (optional, not used in MVP) // Sound for miss (optional, not used in MVP) // Sound for catching bad apple // Sound for catching good apple // Basket // Apple (rotten) // Apple (good) // Game constants var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; var BASKET_Y = GAME_HEIGHT - 200; // Basket near bottom var APPLE_SPAWN_INTERVAL = 45; // Ticks between apples (~0.75s) var TARGET_SCORE = 20; // Win condition // Game state var apples = []; var basket = null; var score = 0; var scoreTxt = null; var dragNode = null; var lastMoveX = null; // Create and position basket basket = new Basket(); basket.x = GAME_WIDTH / 2; basket.y = BASKET_Y; game.addChild(basket); // Score text scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Helper: update score display function updateScoreText() { scoreTxt.setText(score); } // Move handler for dragging basket function handleMove(x, y, obj) { if (dragNode) { // Clamp basket within screen var halfWidth = dragNode.width / 2; var newX = x; if (newX < halfWidth) newX = halfWidth; if (newX > GAME_WIDTH - halfWidth) newX = GAME_WIDTH - halfWidth; dragNode.x = newX; } } // Touch/mouse down: start dragging basket if touch is on basket or anywhere game.down = function (x, y, obj) { // Only allow drag if not in top left 100x100 (reserved for menu) if (x > 100 || y > 100) { dragNode = basket; handleMove(x, y, obj); } }; // Touch/mouse up: stop dragging game.up = function (x, y, obj) { dragNode = null; }; // Touch/mouse move: move basket if dragging game.move = function (x, y, obj) { handleMove(x, y, obj); }; // Main game update loop game.update = function () { // Spawn apples at interval if (LK.ticks % APPLE_SPAWN_INTERVAL === 0) { var apple = new Apple(); // Random x, but keep fully on screen var minX = 80; var maxX = GAME_WIDTH - 80; apple.x = minX + Math.random() * (maxX - minX); apple.y = -80; // Start above screen apples.push(apple); game.addChild(apple); } // Update apples for (var i = apples.length - 1; i >= 0; i--) { var apple = apples[i]; // Track last intersecting state var currentIntersecting = apple.intersects(basket); // If apple just started intersecting with basket if (!apple.lastIntersecting && currentIntersecting) { if (apple.isGood) { score += 1; updateScoreText(); LK.getSound('catchGood').play(); // Flash basket green LK.effects.flashObject(basket, 0x00FF00, 300); } else { score -= 2; if (score < 0) score = 0; updateScoreText(); LK.getSound('catchBad').play(); // Flash basket red LK.effects.flashObject(basket, 0xFF0000, 400); } // Remove apple apple.destroy(); apples.splice(i, 1); continue; } // If apple falls below screen, remove it if (apple.y > GAME_HEIGHT + 100) { apple.destroy(); apples.splice(i, 1); continue; } // Update lastIntersecting apple.lastIntersecting = currentIntersecting; } // Win condition if (score >= TARGET_SCORE) { LK.showYouWin(); return; } }; // Initial score/timer display updateScoreText();
===================================================================
--- original.js
+++ change.js
@@ -11,10 +11,10 @@
var self = Container.call(this);
// Randomly decide if this apple is good or bad
self.isGood = Math.random() < 0.7; // 70% good, 30% bad
// Pick a random color for good and bad apples
- var goodAppleTypes = ['goodApple', 'goodAppleGreen', 'goodAppleYellow'];
- var badAppleTypes = ['badApple', 'badApplePurple', 'badAppleBlue'];
+ var goodAppleTypes = ['goodApple', 'goodAppleGreen', 'goodAppleYellow', 'goodAppleBlue', 'goodApplePurple'];
+ var badAppleTypes = ['badApple', 'badApplePurple', 'badAppleBlue', 'badAppleOrange', 'badApplePink'];
var assetId;
if (self.isGood) {
assetId = goodAppleTypes[Math.floor(Math.random() * goodAppleTypes.length)];
} else {
banana. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
rotten banana. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
apple. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
rotten apple. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
pear. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
rotten pear. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
kiwi . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
rotten kiwi. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
strawberry. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
rotten strawberry. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
hollow fruit basket. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat