User prompt
Didn’t work
User prompt
Fruit should spawn underneath the line
User prompt
Make the line up higher
User prompt
Make the fruit spawn lower
User prompt
Make the fruit spawn under the line
Code edit (1 edits merged)
Please save this source code
User prompt
Fruit Fusion Drop
Initial prompt
Make suika
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Fruit = Container.expand(function (type) { var self = Container.call(this); self.type = type; self.velocityX = 0; self.velocityY = 0; self.gravity = 0.5; self.bounceX = 0.7; self.bounceY = 0.6; self.friction = 0.98; self.merged = false; self.lastMergeCheck = false; var fruitAssets = ['cherry', 'strawberry', 'grape', 'orange', 'apple', 'pear', 'peach', 'pineapple', 'melon', 'watermelon']; var fruitSizes = [60, 80, 100, 120, 140, 160, 180, 200, 220, 240]; var fruitScores = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]; self.assetName = fruitAssets[type]; self.size = fruitSizes[type]; self.scoreValue = fruitScores[type]; var fruitGraphics = self.attachAsset(self.assetName, { anchorX: 0.5, anchorY: 0.5 }); self.getRadius = function () { return self.size / 2; }; self.update = function () { if (self.merged) return; // Apply gravity self.velocityY += self.gravity; // Apply velocity self.x += self.velocityX; self.y += self.velocityY; // Apply friction self.velocityX *= self.friction; self.velocityY *= self.friction; var radius = self.getRadius(); var containerLeft = containerX - containerWidth / 2; var containerRight = containerX + containerWidth / 2; var containerBottom = containerY + containerHeight / 2; // Collision with container walls if (self.x - radius < containerLeft) { self.x = containerLeft + radius; self.velocityX = -self.velocityX * self.bounceX; } if (self.x + radius > containerRight) { self.x = containerRight - radius; self.velocityX = -self.velocityX * self.bounceX; } // Collision with container bottom if (self.y + radius > containerBottom) { self.y = containerBottom - radius; self.velocityY = -self.velocityY * self.bounceY; if (Math.abs(self.velocityY) < 1) { self.velocityY = 0; } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state var fruits = []; var currentFruit = null; var nextFruitType = 0; var gameRunning = true; var dropLine = 200; var gameOverLine = 400; // Container dimensions and position var containerWidth = 800; var containerHeight = 1200; var containerX = 2048 / 2; var containerY = 600; // Create container var container = game.attachAsset('container', { anchorX: 0.5, anchorY: 0.5, x: containerX, y: containerY }); // Score display var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0x000000 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Next fruit preview var nextFruitPreview = null; var nextFruitLabel = new Text2('Next:', { size: 60, fill: 0x000000 }); nextFruitLabel.anchor.set(0.5, 0); nextFruitLabel.x = 1700; nextFruitLabel.y = 200; game.addChild(nextFruitLabel); // Game over line indicator var gameOverIndicator = LK.getAsset('container', { width: containerWidth, height: 4, anchorX: 0.5, anchorY: 0.5 }); gameOverIndicator.x = containerX; gameOverIndicator.y = gameOverLine; gameOverIndicator.tint = 0xFF0000; game.addChild(gameOverIndicator); // Helper functions function getRandomFruitType() { return Math.floor(Math.random() * 5); // Only first 5 fruit types can be dropped } function createNextFruit() { nextFruitType = getRandomFruitType(); if (nextFruitPreview) { nextFruitPreview.destroy(); } var fruitAssets = ['cherry', 'strawberry', 'grape', 'orange', 'apple']; nextFruitPreview = LK.getAsset(fruitAssets[nextFruitType], { anchorX: 0.5, anchorY: 0.5 }); nextFruitPreview.x = 1700; nextFruitPreview.y = 300; game.addChild(nextFruitPreview); } function dropFruit(x) { if (!gameRunning || currentFruit) return; currentFruit = new Fruit(nextFruitType); currentFruit.x = Math.max(containerX - containerWidth / 2 + currentFruit.getRadius(), Math.min(x, containerX + containerWidth / 2 - currentFruit.getRadius())); currentFruit.y = dropLine + currentFruit.getRadius() + 10; fruits.push(currentFruit); game.addChild(currentFruit); LK.getSound('drop').play(); // Reset current fruit after a delay LK.setTimeout(function () { currentFruit = null; }, 100); createNextFruit(); } function checkCollision(fruit1, fruit2) { var dx = fruit1.x - fruit2.x; var dy = fruit1.y - fruit2.y; var distance = Math.sqrt(dx * dx + dy * dy); var minDistance = fruit1.getRadius() + fruit2.getRadius(); return distance < minDistance; } function resolveFruitCollision(fruit1, fruit2) { var dx = fruit1.x - fruit2.x; var dy = fruit1.y - fruit2.y; var distance = Math.sqrt(dx * dx + dy * dy); var minDistance = fruit1.getRadius() + fruit2.getRadius(); if (distance < minDistance && distance > 0) { var overlap = minDistance - distance; var separationX = dx / distance * overlap * 0.5; var separationY = dy / distance * overlap * 0.5; fruit1.x += separationX; fruit1.y += separationY; fruit2.x -= separationX; fruit2.y -= separationY; // Simple collision response var tempVelX = fruit1.velocityX; var tempVelY = fruit1.velocityY; fruit1.velocityX = fruit2.velocityX * 0.5; fruit1.velocityY = fruit2.velocityY * 0.5; fruit2.velocityX = tempVelX * 0.5; fruit2.velocityY = tempVelY * 0.5; } } function mergeFruits(fruit1, fruit2) { if (fruit1.type !== fruit2.type || fruit1.merged || fruit2.merged) return false; if (fruit1.type >= 9) return false; // Can't merge watermelon // Create new fruit var newFruit = new Fruit(fruit1.type + 1); newFruit.x = (fruit1.x + fruit2.x) / 2; newFruit.y = (fruit1.y + fruit2.y) / 2; // Add score LK.setScore(LK.getScore() + newFruit.scoreValue); scoreTxt.setText('Score: ' + LK.getScore()); // Mark old fruits as merged fruit1.merged = true; fruit2.merged = true; // Remove old fruits for (var i = fruits.length - 1; i >= 0; i--) { if (fruits[i] === fruit1 || fruits[i] === fruit2) { fruits[i].destroy(); fruits.splice(i, 1); } } // Add new fruit fruits.push(newFruit); game.addChild(newFruit); LK.getSound('merge').play(); // Flash effect tween(newFruit, { scaleX: 1.3, scaleY: 1.3 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(newFruit, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200, easing: tween.easeIn }); } }); return true; } function checkGameOver() { for (var i = 0; i < fruits.length; i++) { var fruit = fruits[i]; if (fruit.y - fruit.getRadius() < gameOverLine) { return true; } } return false; } // Initialize first fruit createNextFruit(); // Event handlers game.down = function (x, y, obj) { if (!gameRunning) return; dropFruit(x); }; // Main game loop game.update = function () { if (!gameRunning) return; // Update all fruits for (var i = 0; i < fruits.length; i++) { fruits[i].update(); } // Check collisions and merges for (var i = 0; i < fruits.length; i++) { for (var j = i + 1; j < fruits.length; j++) { var fruit1 = fruits[i]; var fruit2 = fruits[j]; if (fruit1.merged || fruit2.merged) continue; if (checkCollision(fruit1, fruit2)) { // Check for merge first var currentMerging = fruit1.type === fruit2.type; if (!fruit1.lastMergeCheck && currentMerging) { if (mergeFruits(fruit1, fruit2)) { break; // Break out of inner loop as fruits array changed } } else if (!currentMerging) { resolveFruitCollision(fruit1, fruit2); } fruit1.lastMergeCheck = currentMerging; fruit2.lastMergeCheck = currentMerging; } else { fruit1.lastMergeCheck = false; fruit2.lastMergeCheck = false; } } } // Check game over condition if (checkGameOver() && LK.ticks % 60 === 0) { // Check every second gameRunning = false; LK.showGameOver(); } };
===================================================================
--- original.js
+++ change.js
@@ -79,10 +79,10 @@
var fruits = [];
var currentFruit = null;
var nextFruitType = 0;
var gameRunning = true;
-var dropLine = 400;
-var gameOverLine = 500;
+var dropLine = 200;
+var gameOverLine = 400;
// Container dimensions and position
var containerWidth = 800;
var containerHeight = 1200;
var containerX = 2048 / 2;
Apple with cute face. In-Game asset. 2d. High contrast. No shadows
Cherry with cute face. In-Game asset. 2d. High contrast. No shadows
Greyish blue square. In-Game asset. 2d. High contrast. No shadows
Grapes with a cute face. In-Game asset. 2d. High contrast. No shadows
Circle water melon with cute face. In-Game asset. 2d. High contrast. No shadows
Circle cantaloupe with cute face. In-Game asset. 2d. High contrast. No shadows
Pear with cute face. In-Game asset. 2d. High contrast. No shadows
Strawberry with cute face. In-Game asset. 2d. High contrast. No shadows
Orange with cute face. In-Game asset. 2d. High contrast. No shadows
Peach with cute face. In-Game asset. 2d. High contrast. No shadows
Pineapple with cute face. In-Game asset. 2d. High contrast. No shadows
Dragon fruit with cute face. In-Game asset. 2d. High contrast. No shadows
Lemon with cute face. In-Game asset. 2d. High contrast. No shadows
Kiwi with cute face. In-Game asset. 2d. High contrast. No shadows
Coconut with cute face. In-Game asset. 2d. High contrast. No shadows