User prompt
Meyvelerin kesilme animasyonları olsun.
User prompt
Meyve kesince puan artmıyor.
User prompt
Meyveler her 2 saniyede bir çıksın
User prompt
Meyveler her 3 saniyede bir çıksın. Bombalar ise her 5 saniyede bir çıksın.
User prompt
Meyvelerin boyutları baya büyüt.
User prompt
Meyveler daha fazla fırlasın ama ekranın sağ ve solundan geçemesinler
User prompt
Meyveler geri düşünce x artmasın sadece bombaya dokunduğumuzda x artsın.
User prompt
Meyve çıkma olasılığını düşür.
User prompt
Meyveler çok azıcık daha fırlasın
User prompt
Meyveler daha az fırlasın
User prompt
Meyvelerin çıkma süresini azalat. Meyveler teker teker çıksın.
User prompt
Hepsinin asetini assets kısmına ekls
User prompt
Meyveleri baya fırlat
User prompt
Meyveler daha yükseğe çıksın ama daha yavaş olsunlar.
User prompt
Meyveler daha yavaş çıksın
User prompt
Meyveler ekranın sağ ve solu çok hızlı bir şekilde gidiyor bunu düzelt.
Code edit (1 edits merged)
Please save this source code
User prompt
Fruit Ninja Slice
Initial prompt
Fruit Ninja
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // Bomb class var Bomb = Container.expand(function () { var self = Container.call(this); // Bomb asset: black circle with red border var assetId = 'bomb'; var bombGfx = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Add a red border by overlaying a slightly larger ellipse var borderId = 'bomb_border'; var borderGfx = self.attachAsset(borderId, { anchorX: 0.5, anchorY: 0.5, alpha: 0.3 }); // Physics self.vx = 0; self.vy = 0; self.gravity = 0.35 + Math.random() * 0.1; self.sliced = false; self.slice = function () { if (self.sliced) return; self.sliced = true; // Animate: flash and fade out tween(self, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 250, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; self.update = function () { if (self.sliced) return; self.x += self.vx; self.y += self.vy; self.vy += self.gravity; }; return self; }); // Fruit class var Fruit = Container.expand(function () { var self = Container.call(this); // Fruit types: apple, banana, orange, watermelon, etc. // Each type has a color and shape // We'll use 'ellipse' for round fruits, 'box' for banana // We'll randomize type on creation var types = [{ id: 'apple', color: 0xff2d2d, shape: 'ellipse', width: 120, height: 120, points: 1 }, { id: 'orange', color: 0xffa500, shape: 'ellipse', width: 110, height: 110, points: 1 }, { id: 'banana', color: 0xfff700, shape: 'box', width: 160, height: 60, points: 2 }, { id: 'watermelon', color: 0x2ecc40, shape: 'ellipse', width: 160, height: 160, points: 3 }, { id: 'kiwi', color: 0x8ee53f, shape: 'ellipse', width: 100, height: 100, points: 2 }]; var type = types[Math.floor(Math.random() * types.length)]; // Asset id is unique per type var assetId = 'fruit_' + type.id; // Initialize asset if not already var fruitGfx = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Physics self.vx = 0; self.vy = 0; self.gravity = 0.35 + Math.random() * 0.1; self.sliced = false; self.points = type.points; // For arc motion, we set vx, vy on spawn // Slicing animation self.slice = function () { if (self.sliced) return; self.sliced = true; // Animate: scale up and fade out tween(self, { scaleX: 1.4, scaleY: 1.4, alpha: 0 }, { duration: 350, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; // Update per frame self.update = function () { if (self.sliced) return; self.x += self.vx; self.y += self.vy; self.vy += self.gravity; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ // Game variables var fruits = []; var bombs = []; var spawnTimer = 0; var spawnInterval = 60; // frames (1s) var difficultyTimer = 0; var minSpawnInterval = 22; // ~0.36s var maxFruitsPerWave = 3; var score = 0; var highScore = storage.highScore || 0; var missed = 0; var maxMissed = 3; var isGameOver = false; // Score display var scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // High score display (smaller, top right) var highScoreTxt = new Text2('Best: ' + highScore, { size: 60, fill: "#fff" }); highScoreTxt.anchor.set(1, 0); LK.gui.topRight.addChild(highScoreTxt); // Missed fruits display (bottom left, as X icons) var missTxt = new Text2('', { size: 90, fill: 0xFF4444 }); missTxt.anchor.set(0, 1); LK.gui.bottomLeft.addChild(missTxt); // Helper: update score function updateScore(val) { score = val; scoreTxt.setText(score); if (score > highScore) { highScore = score; storage.highScore = highScore; highScoreTxt.setText('Best: ' + highScore); } } // Helper: update missed display function updateMissed() { var s = ''; for (var i = 0; i < missed; i++) s += '✗ '; missTxt.setText(s); } // Helper: spawn a fruit or bomb function spawnObject() { // Randomly decide: bomb or fruit var isBomb = Math.random() < Math.max(0.08, 0.12 - score * 0.0015); // Bomb chance increases with score var obj; var x = 200 + Math.random() * (2048 - 400); var y = 2732 + 60; // Start just below screen var angle = -Math.PI / 2 + (Math.random() - 0.5) * Math.PI / 2; // Upwards, with spread var speed = 32 + Math.random() * 10 + score * 0.12; // Increase speed with score // Reduce horizontal speed for less extreme left/right movement var vx = Math.cos(angle) * speed * (Math.random() * 0.22 + 0.25); var vy = -Math.abs(Math.sin(angle) * speed); if (isBomb) { obj = new Bomb(); bombs.push(obj); } else { obj = new Fruit(); fruits.push(obj); } obj.x = x; obj.y = y; obj.vx = vx; obj.vy = vy; obj.scaleX = obj.scaleY = 1; obj.alpha = 1; game.addChild(obj); } // Helper: spawn a wave function spawnWave() { var n = 1 + Math.floor(Math.random() * maxFruitsPerWave); for (var i = 0; i < n; i++) { spawnObject(); } } // Slicing logic var swipePath = []; var swipeMaxLength = 12; // Number of points to keep in swipe trail var swipeRadius = 90; // How close swipe must be to slice // Draw swipe trail (for visual feedback) var swipeTrail = []; function drawSwipeTrail() { // Remove old for (var i = 0; i < swipeTrail.length; i++) { swipeTrail[i].destroy(); } swipeTrail = []; // Draw new for (var i = 1; i < swipePath.length; i++) { var p1 = swipePath[i - 1]; var p2 = swipePath[i]; // Draw a short white ellipse between points var dx = p2.x - p1.x, dy = p2.y - p1.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < 10) continue; var angle = Math.atan2(dy, dx); var id = 'swipe_' + i; var seg = LK.getAsset(id, { anchorX: 0, anchorY: 0.5, x: p1.x, y: p1.y, rotation: angle, alpha: 0.22 }); game.addChild(seg); swipeTrail.push(seg); } } // Handle swipe start game.down = function (x, y, obj) { if (isGameOver) return; swipePath = [{ x: x, y: y }]; drawSwipeTrail(); }; // Handle swipe move game.move = function (x, y, obj) { if (isGameOver) return; swipePath.push({ x: x, y: y }); if (swipePath.length > swipeMaxLength) swipePath.shift(); drawSwipeTrail(); // For each segment in swipe, check for intersection with fruits/bombs for (var i = 1; i < swipePath.length; i++) { var p1 = swipePath[i - 1], p2 = swipePath[i]; // Fruits for (var f = fruits.length - 1; f >= 0; f--) { var fruit = fruits[f]; if (fruit.sliced) continue; // If fruit already off screen, skip if (fruit.y > 2732 + 120) continue; // Check if swipe segment is close to fruit center var cx = fruit.x, cy = fruit.y; var dist = pointToSegmentDistance(cx, cy, p1.x, p1.y, p2.x, p2.y); if (dist < swipeRadius) { fruit.slice(); updateScore(score + fruit.points); fruits.splice(f, 1); // Flash effect LK.effects.flashObject(fruit, 0xffffff, 120); } } // Bombs for (var b = bombs.length - 1; b >= 0; b--) { var bomb = bombs[b]; if (bomb.sliced) continue; if (bomb.y > 2732 + 120) continue; var cx = bomb.x, cy = bomb.y; var dist = pointToSegmentDistance(cx, cy, p1.x, p1.y, p2.x, p2.y); if (dist < swipeRadius) { bomb.slice(); bombs.splice(b, 1); // Flash screen red, then game over LK.effects.flashScreen(0xff2222, 800); isGameOver = true; LK.setTimeout(function () { LK.showGameOver(); }, 600); return; } } } }; // Handle swipe end game.up = function (x, y, obj) { swipePath = []; drawSwipeTrail(); }; // Helper: distance from point to segment function pointToSegmentDistance(px, py, x1, y1, x2, y2) { var dx = x2 - x1, dy = y2 - y1; if (dx === 0 && dy === 0) { dx = px - x1; dy = py - y1; return Math.sqrt(dx * dx + dy * dy); } var t = ((px - x1) * dx + (py - y1) * dy) / (dx * dx + dy * dy); t = Math.max(0, Math.min(1, t)); var lx = x1 + t * dx, ly = y1 + t * dy; dx = px - lx; dy = py - ly; return Math.sqrt(dx * dx + dy * dy); } // Main game update game.update = function () { if (isGameOver) return; // Spawn logic spawnTimer++; difficultyTimer++; if (spawnTimer >= spawnInterval) { spawnWave(); spawnTimer = 0; // Decrease interval for difficulty if (spawnInterval > minSpawnInterval && difficultyTimer % 600 === 0) { spawnInterval -= 4; if (maxFruitsPerWave < 5 && difficultyTimer % 1200 === 0) maxFruitsPerWave++; } } // Update fruits for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; fruit.update(); // Remove if off screen if (!fruit.sliced && fruit.y > 2732 + 120) { fruit.destroy(); fruits.splice(i, 1); missed++; updateMissed(); // Flash screen if missed LK.effects.flashScreen(0x2222ff, 200); if (missed >= maxMissed) { isGameOver = true; LK.setTimeout(function () { LK.showGameOver(); }, 500); } } } // Update bombs for (var i = bombs.length - 1; i >= 0; i--) { var bomb = bombs[i]; bomb.update(); if (bomb.y > 2732 + 120) { bomb.destroy(); bombs.splice(i, 1); } } // Fade out swipe trail for (var i = 0; i < swipeTrail.length; i++) { swipeTrail[i].alpha *= 0.85; if (swipeTrail[i].alpha < 0.05) { swipeTrail[i].destroy(); swipeTrail.splice(i, 1); i--; } } }; // Reset game state on new game game.on('reset', function () { // Remove all fruits and bombs for (var i = 0; i < fruits.length; i++) fruits[i].destroy(); for (var i = 0; i < bombs.length; i++) bombs[i].destroy(); fruits = []; bombs = []; spawnTimer = 0; spawnInterval = 60; difficultyTimer = 0; maxFruitsPerWave = 3; score = 0; missed = 0; isGameOver = false; updateScore(0); updateMissed(); swipePath = []; drawSwipeTrail(); highScore = storage.highScore || 0; highScoreTxt.setText('Best: ' + highScore); }); // Initial state updateScore(0); updateMissed();
===================================================================
--- original.js
+++ change.js
@@ -205,9 +205,10 @@
var x = 200 + Math.random() * (2048 - 400);
var y = 2732 + 60; // Start just below screen
var angle = -Math.PI / 2 + (Math.random() - 0.5) * Math.PI / 2; // Upwards, with spread
var speed = 32 + Math.random() * 10 + score * 0.12; // Increase speed with score
- var vx = Math.cos(angle) * speed * (Math.random() * 0.5 + 0.7);
+ // Reduce horizontal speed for less extreme left/right movement
+ var vx = Math.cos(angle) * speed * (Math.random() * 0.22 + 0.25);
var vy = -Math.abs(Math.sin(angle) * speed);
if (isBomb) {
obj = new Bomb();
bombs.push(obj);