User prompt
top score yazısı için bir asset oluştur yanınada top scoru yazarsı
User prompt
top score yazısını sil
User prompt
top score yazısını durdurma butonunun yanına al
User prompt
top score yazısını hala göremiyorum onu sil ve yeniden ana menüye yerleştir
User prompt
çok az daha
User prompt
play butonunu çok az sağa kaydır
User prompt
top score yazısı görünmüyor
User prompt
top sore yazısı play butonu ile aynı boyutta olsun
User prompt
top score yazısı daha büyük olsun
User prompt
daha büyük olsun
User prompt
ana menüdeki play butonun altına top score için bi yer yap
User prompt
3 olan kaybetme hakkımız 5 olsun ve o çarpılar için bir asset ekle
User prompt
bomba assetini biraz daha büyüt
User prompt
bomba assetini meyvelerin yarısı olacak kadar kbüyüt
User prompt
bomba assteini 1 kat büyüt
User prompt
bomba assetini 1.5 kat büyüt
User prompt
bomba ssetini biraz küçült
User prompt
bomba assetini 2 kat büyüt
User prompt
23. koddaki sorun ne ve düzelt
User prompt
Please fix the bug: 'Error: Invalid end type for property stroke: string' in or related to this line: 'tween(comboTxt, {' Line Number: 525
User prompt
Please fix the bug: 'Error: Invalid end type for property stroke: string' in or related to this line: 'tween(comboTxt, {' Line Number: 525
User prompt
Please fix the bug: 'Error: Invalid end type for property stroke: string' in or related to this line: 'tween(comboTxt, {' Line Number: 525
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(comboTxt, {' Line Number: 512
User prompt
combo yazısını daha havalı yapalım
User prompt
combo yazısını daha şaafatlı yapalım
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Bomb class: Represents a bomb flying through the air var Bomb = Container.expand(function () { var self = Container.call(this); self.sliced = false; self.missed = false; // Attach bomb asset (black ellipse) var bombAsset = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2, color: 0x222222, shape: 'ellipse' }); // Add a white "fuse" (small rectangle) var fuse = self.attachAsset('fuse', { anchorX: 0.5, anchorY: 1, width: 20, height: 50, color: 0xffffff, shape: 'box', y: -80 }); // Set initial position and velocity (to be set by spawner) self.x = 0; self.y = 0; self.vx = 0; self.vy = 0; self.gravity = 0.35 + Math.random() * 0.1; self.lastY = self.y; self.update = function () { if (self.sliced) return; self.x += self.vx; self.y += self.vy; self.vy += self.gravity; bombAsset.rotation += 0.09; if (!self.missed && self.y > 2732 + 100) { self.missed = true; } }; self.slice = function () { if (self.sliced) return; self.sliced = true; // Animate: flash red and fade out tween(self, { scaleX: 1.7, scaleY: 1.7, alpha: 0 }, { duration: 250, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); // Fruit class: Represents a fruit flying through the air var Fruit = Container.expand(function () { var self = Container.call(this); // Fruit types and their properties var fruitTypes = [{ id: 'apple', color: 0xff2d2d, points: 1 }, { id: 'banana', color: 0xfff700, points: 2 }, { id: 'orange', color: 0xffa500, points: 3 }, { id: 'watermelon', color: 0x2ecc40, points: 5 }, { id: 'grape', color: 0x8e44ad, points: 4 }, { id: 'kiwi', color: 0x7ed957, points: 3 }, { id: 'lemon', color: 0xfff700, points: 2 }, { id: 'strawberry', color: 0xff3b6b, points: 4 }, { id: 'blueberry', color: 0x3b5fff, points: 4 }, { id: 'pineapple', color: 0xffe066, points: 5 }]; // Randomly pick a fruit type var typeIndex = Math.floor(Math.random() * fruitTypes.length); var type = fruitTypes[typeIndex]; self.fruitType = type.id; self.points = type.points; self.sliced = false; self.missed = false; // Attach fruit asset (ellipse for fruit) var fruitAsset = self.attachAsset(type.id, { anchorX: 0.5, anchorY: 0.5, width: 320, height: 320, color: type.color, shape: 'ellipse' }); // Give fruit a random initial rotation fruitAsset.rotation = Math.random() * Math.PI * 2; // Set initial position and velocity (to be set by spawner) self.x = 0; self.y = 0; self.vx = 0; self.vy = 0; self.gravity = 0.35 + Math.random() * 0.1; // For tracking if fruit is out of bounds self.lastY = self.y; // For combo detection self.sliceTick = -1; // Animate fruit (arc trajectory) self.update = function () { if (self.sliced) return; // Don't update if already sliced self.x += self.vx; self.y += self.vy; self.vy += self.gravity; // Spin fruit fruitAsset.rotation += 0.07; // If fruit falls below screen, mark as missed if (!self.missed && self.y > 2732 + 100) { self.missed = true; } }; // Slice the fruit self.slice = function () { if (self.sliced) return; self.sliced = true; // Animate: scale up and fade out tween(self, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 350, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222a36 }); /**** * Game Code ****/ // --- GLOBALS --- // Fruit assets var fruits = []; var bombs = []; var missedFruits = 0; var maxMissed = 3; var comboWindow = 20; // ticks for combo var lastSliceTick = -100; var comboCount = 0; var backgroundIndex = 0; var backgrounds = [{ id: 'bg1', color: 0x222a36 }, { id: 'bg2', color: 0x1a3d2f }, { id: 'bg3', color: 0x3d1a2f }, { id: 'bg4', color: 0x1e1e2f }]; // --- MAIN MENU STATE --- var isGameStarted = false; // Main menu container var mainMenu = new Container(); // Main menu background (reuse bg4) var menuBg = LK.getAsset('bg4', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732 }); mainMenu.addChild(menuBg); // "Play" button (now using 'by furkan' asset) var playBtn = LK.getAsset('byfurkan', { anchorX: 0.5, anchorY: 0.5, width: 400 * 2, height: 180 * 2 }); playBtn.x = 2048 / 2; playBtn.y = 2732 / 2 + 400; mainMenu.addChild(playBtn); var playBtnTxt = new Text2('PLAY', { size: 120, fill: "#fff", font: "bold 900 120px Arial, 'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); playBtnTxt.anchor.set(0.5, 0.5); playBtnTxt.x = playBtn.x; playBtnTxt.y = playBtn.y; mainMenu.addChild(playBtnTxt); // Top score text for menu var menuTopScoreTxt = new Text2('Top Score: 0', { size: 120, fill: "#000", font: "bold 900 120px Arial, 'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); menuTopScoreTxt.anchor.set(1, 0); menuTopScoreTxt.x = 2048 - 40; menuTopScoreTxt.y = 40; mainMenu.addChild(menuTopScoreTxt); // Show main menu at start game.addChild(mainMenu); // Play button event playBtn.down = function (x, y, obj) { isGameStarted = true; mainMenu.visible = false; // Reset game state resetGame(); }; // Helper to update menu top score function updateMenuTopScore(val) { menuTopScoreTxt.setText('Top Score: ' + val); } // --- GUI Elements --- // Score text var scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // High score (best combo) text var bestComboTxt = new Text2('Best: 0', { size: 120, fill: "#000", font: "bold 900 120px Arial, 'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); bestComboTxt.anchor.set(1, 0); // right edge, top bestComboTxt.x = 0; // x=0 in LK.gui.topRight is the right edge bestComboTxt.y = 0; LK.gui.topRight.addChild(bestComboTxt); // Missed fruits indicator (bottom left, red X's) var missedTxt = new Text2('', { size: 90, fill: 0xFF4444 }); missedTxt.anchor.set(0, 1); LK.gui.bottomLeft.addChild(missedTxt); // Combo text (center, fades out) var comboTxt = new Text2('', { size: 180, fill: 0xFFE066 }); comboTxt.anchor.set(0.5, 0.5); comboTxt.alpha = 0; LK.gui.center.addChild(comboTxt); // Background switch button (bottom right) var bgBtn = LK.getAsset('bgBtn', { anchorX: 1, anchorY: 1, width: 180, height: 100, color: 0x8888ff, shape: 'box' }); bgBtn.x = 0; bgBtn.y = 0; LK.gui.bottomRight.addChild(bgBtn); var bgBtnTxt = new Text2('BG', { size: 60, fill: "#fff" }); bgBtnTxt.anchor.set(0.5, 0.5); bgBtnTxt.x = -90; bgBtnTxt.y = -50; LK.gui.bottomRight.addChild(bgBtnTxt); // --- BACKGROUND --- // Fullscreen background image node var bgImageNode = LK.getAsset('bg4', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732 }); game.addChild(bgImageNode); function setBackground(idx) { backgroundIndex = idx % backgrounds.length; // Always keep background image behind everything if (bgImageNode.parent) { game.setChildIndex(bgImageNode, 0); } // Optionally, you could swap image asset here if you want to support more backgrounds game.setBackgroundColor(backgrounds[backgroundIndex].color); } setBackground(0); // --- FRUIT & BOMB SPAWNING --- function spawnFruitOrBomb() { // Randomly decide: 80% fruit, 20% bomb var isBomb = Math.random() < 0.2; var obj; // Spawn X within safe bounds var x = 320 + Math.random() * (2048 - 640); var y = 2732 + 80; // Calculate angle so fruit always arcs toward center var centerX = 2048 / 2; var dx = centerX - x; var minAngle = -Math.PI / 2 - Math.PI / 6; // -120deg var maxAngle = -Math.PI / 2 + Math.PI / 6; // -60deg // Angle toward center, with a little random spread var baseAngle = Math.atan2(-1200, dx); var angle = baseAngle + (Math.random() - 0.5) * (Math.PI / 12); // small random spread // Clamp angle to safe range if (angle < minAngle) angle = minAngle; if (angle > maxAngle) angle = maxAngle; var speed = 38 + Math.random() * 10; if (isBomb) { obj = new Bomb(); bombs.push(obj); } else { obj = new Fruit(); fruits.push(obj); } obj.x = x; obj.y = y; obj.vx = Math.cos(angle) * speed; obj.vy = Math.sin(angle) * speed; game.addChild(obj); } // --- GAME LOGIC --- // Slicing logic: track swipe path and check for intersection var swipePath = []; var swipeMaxLength = 8; // Only keep last 8 points // Hide gameplay GUI until game starts scoreTxt.visible = false; bestComboTxt.visible = false; missedTxt.visible = false; comboTxt.visible = false; bgBtn.visible = false; bgBtnTxt.visible = false; // Show/hide GUI based on game state function updateGUIVisibility() { var show = isGameStarted; scoreTxt.visible = show; bestComboTxt.visible = show; missedTxt.visible = show; comboTxt.visible = show; bgBtn.visible = show; bgBtnTxt.visible = show; } // Call this after Play is pressed function startGame() { isGameStarted = true; mainMenu.visible = false; updateGUIVisibility(); resetGame(); } // Overwrite playBtn.down to use startGame playBtn.down = function (x, y, obj) { startGame(); }; function handleSlice(x, y) { if (!isGameStarted) return; // Check fruits for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; if (fruit.sliced) continue; // If swipe is close to fruit center (distance < 120) var dx = fruit.x - x; var dy = fruit.y - y; if (dx * dx + dy * dy < 120 * 120) { fruit.slice(); // Combo logic if (lastSliceTick > 0 && LK.ticks - lastSliceTick < comboWindow) { comboCount++; } else { comboCount = 1; } lastSliceTick = LK.ticks; // Combo multiplier: 1x for single, 2x for double, 3x for triple or more var comboMultiplier = 1; if (comboCount === 2) comboMultiplier = 2; if (comboCount >= 3) comboMultiplier = 3; // Each fruit is worth 10 points, multiplied by combo var pointsEarned = 10 * comboMultiplier; LK.setScore(LK.getScore() + pointsEarned); scoreTxt.setText(LK.getScore()); // Show combo text if comboCount >= 2 if (comboCount >= 2) { showCombo(comboCount); } // Track best combo if (typeof bestCombo === "undefined") { bestCombo = 0; } if (comboCount > bestCombo) { bestCombo = comboCount; bestComboTxt.setText('Best: ' + bestCombo); } fruit.sliceTick = LK.ticks; } } // Check bombs for (var j = bombs.length - 1; j >= 0; j--) { var bomb = bombs[j]; if (bomb.sliced) continue; var dx = bomb.x - x; var dy = bomb.y - y; if (dx * dx + dy * dy < 120 * 120) { bomb.slice(); // Game over LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); return; } } } // Show combo text function showCombo(count) { if (count < 2) return; comboTxt.setText('Combo x' + count + '!'); comboTxt.alpha = 1; comboTxt.scaleX = 1.8; comboTxt.scaleY = 1.8; comboTxt.fill = "#FFD700"; // Gold color for extra flash // Animate: scale down, fade out, and color back to yellow tween(comboTxt, { scaleX: 1, scaleY: 1, alpha: 0, fill: 0xFFE066 }, { duration: 900, easing: tween.easeOut, onUpdate: function onUpdate() { // Defensive: ensure fill is always a string if (typeof comboTxt.fill !== "string") comboTxt.fill = "#FFE066"; } }); } // Update missed fruits display function updateMissed() { var s = ''; for (var i = 0; i < missedFruits; i++) s += '✗ '; missedTxt.setText(s); } // --- INPUT HANDLING --- // Swiping: track move events, draw path, and slice game.move = function (x, y, obj) { if (!isGameStarted) return; // Don't allow swipes in top left 100x100 if (x < 100 && y < 100) return; // Add to swipe path swipePath.push({ x: x, y: y, tick: LK.ticks }); if (swipePath.length > swipeMaxLength) swipePath.shift(); // For each point in swipe path, check for slicing for (var i = 0; i < swipePath.length; i++) { handleSlice(swipePath[i].x, swipePath[i].y); } }; // On down, start new swipe game.down = function (x, y, obj) { if (!isGameStarted) return; swipePath = [{ x: x, y: y, tick: LK.ticks }]; handleSlice(x, y); }; // On up, clear swipe path game.up = function (x, y, obj) { if (!isGameStarted) return; swipePath = []; }; // Background button: tap to change background bgBtn.down = function (x, y, obj) { setBackground((backgroundIndex + 1) % backgrounds.length); }; // --- GAME UPDATE LOOP --- game.update = function () { if (!isGameStarted) { updateGUIVisibility(); return; } updateGUIVisibility(); // Spawn fruits/bombs every 35-55 ticks if (LK.ticks % (35 + Math.floor(Math.random() * 20)) === 0) { spawnFruitOrBomb(); } // Update fruits for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; // Remove if destroyed if (fruit.destroyed) { fruits.splice(i, 1); continue; } // If missed if (fruit.missed && !fruit.sliced) { fruits.splice(i, 1); missedFruits++; updateMissed(); LK.effects.flashObject(missedTxt, 0xff0000, 400); if (missedFruits >= maxMissed) { LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); return; } } } // Update bombs for (var j = bombs.length - 1; j >= 0; j--) { var bomb = bombs[j]; if (bomb.destroyed) { bombs.splice(j, 1); continue; } } // Combo reset if (comboCount > 1 && LK.ticks - lastSliceTick > comboWindow) { comboCount = 0; } }; // --- GAME RESET HANDLING --- // On game reset, clear all arrays and reset state function resetGame() { fruits = []; bombs = []; missedFruits = 0; comboCount = 0; lastSliceTick = -100; scoreTxt.setText('0'); comboTxt.setText(''); comboTxt.alpha = 0; updateMissed(); setBackground(0); // Only reset bestCombo if not started, otherwise keep best score if (!isGameStarted) { bestCombo = 0; bestComboTxt.setText('Best: 0'); updateMenuTopScore(0); } else { bestComboTxt.setText('Best: ' + (typeof bestCombo !== "undefined" ? bestCombo : 0)); updateMenuTopScore(typeof bestCombo !== "undefined" ? bestCombo : 0); } } resetGame(); // --- END OF GAME CODE ---
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Bomb class: Represents a bomb flying through the air
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.sliced = false;
self.missed = false;
// Attach bomb asset (black ellipse)
var bombAsset = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
color: 0x222222,
shape: 'ellipse'
});
// Add a white "fuse" (small rectangle)
var fuse = self.attachAsset('fuse', {
anchorX: 0.5,
anchorY: 1,
width: 20,
height: 50,
color: 0xffffff,
shape: 'box',
y: -80
});
// Set initial position and velocity (to be set by spawner)
self.x = 0;
self.y = 0;
self.vx = 0;
self.vy = 0;
self.gravity = 0.35 + Math.random() * 0.1;
self.lastY = self.y;
self.update = function () {
if (self.sliced) return;
self.x += self.vx;
self.y += self.vy;
self.vy += self.gravity;
bombAsset.rotation += 0.09;
if (!self.missed && self.y > 2732 + 100) {
self.missed = true;
}
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
// Animate: flash red and fade out
tween(self, {
scaleX: 1.7,
scaleY: 1.7,
alpha: 0
}, {
duration: 250,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
// Fruit class: Represents a fruit flying through the air
var Fruit = Container.expand(function () {
var self = Container.call(this);
// Fruit types and their properties
var fruitTypes = [{
id: 'apple',
color: 0xff2d2d,
points: 1
}, {
id: 'banana',
color: 0xfff700,
points: 2
}, {
id: 'orange',
color: 0xffa500,
points: 3
}, {
id: 'watermelon',
color: 0x2ecc40,
points: 5
}, {
id: 'grape',
color: 0x8e44ad,
points: 4
}, {
id: 'kiwi',
color: 0x7ed957,
points: 3
}, {
id: 'lemon',
color: 0xfff700,
points: 2
}, {
id: 'strawberry',
color: 0xff3b6b,
points: 4
}, {
id: 'blueberry',
color: 0x3b5fff,
points: 4
}, {
id: 'pineapple',
color: 0xffe066,
points: 5
}];
// Randomly pick a fruit type
var typeIndex = Math.floor(Math.random() * fruitTypes.length);
var type = fruitTypes[typeIndex];
self.fruitType = type.id;
self.points = type.points;
self.sliced = false;
self.missed = false;
// Attach fruit asset (ellipse for fruit)
var fruitAsset = self.attachAsset(type.id, {
anchorX: 0.5,
anchorY: 0.5,
width: 320,
height: 320,
color: type.color,
shape: 'ellipse'
});
// Give fruit a random initial rotation
fruitAsset.rotation = Math.random() * Math.PI * 2;
// Set initial position and velocity (to be set by spawner)
self.x = 0;
self.y = 0;
self.vx = 0;
self.vy = 0;
self.gravity = 0.35 + Math.random() * 0.1;
// For tracking if fruit is out of bounds
self.lastY = self.y;
// For combo detection
self.sliceTick = -1;
// Animate fruit (arc trajectory)
self.update = function () {
if (self.sliced) return; // Don't update if already sliced
self.x += self.vx;
self.y += self.vy;
self.vy += self.gravity;
// Spin fruit
fruitAsset.rotation += 0.07;
// If fruit falls below screen, mark as missed
if (!self.missed && self.y > 2732 + 100) {
self.missed = true;
}
};
// Slice the fruit
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
// Animate: scale up and fade out
tween(self, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 350,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x222a36
});
/****
* Game Code
****/
// --- GLOBALS ---
// Fruit assets
var fruits = [];
var bombs = [];
var missedFruits = 0;
var maxMissed = 3;
var comboWindow = 20; // ticks for combo
var lastSliceTick = -100;
var comboCount = 0;
var backgroundIndex = 0;
var backgrounds = [{
id: 'bg1',
color: 0x222a36
}, {
id: 'bg2',
color: 0x1a3d2f
}, {
id: 'bg3',
color: 0x3d1a2f
}, {
id: 'bg4',
color: 0x1e1e2f
}];
// --- MAIN MENU STATE ---
var isGameStarted = false;
// Main menu container
var mainMenu = new Container();
// Main menu background (reuse bg4)
var menuBg = LK.getAsset('bg4', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
mainMenu.addChild(menuBg);
// "Play" button (now using 'by furkan' asset)
var playBtn = LK.getAsset('byfurkan', {
anchorX: 0.5,
anchorY: 0.5,
width: 400 * 2,
height: 180 * 2
});
playBtn.x = 2048 / 2;
playBtn.y = 2732 / 2 + 400;
mainMenu.addChild(playBtn);
var playBtnTxt = new Text2('PLAY', {
size: 120,
fill: "#fff",
font: "bold 900 120px Arial, 'GillSans-Bold', Impact, 'Arial Black', Tahoma"
});
playBtnTxt.anchor.set(0.5, 0.5);
playBtnTxt.x = playBtn.x;
playBtnTxt.y = playBtn.y;
mainMenu.addChild(playBtnTxt);
// Top score text for menu
var menuTopScoreTxt = new Text2('Top Score: 0', {
size: 120,
fill: "#000",
font: "bold 900 120px Arial, 'GillSans-Bold', Impact, 'Arial Black', Tahoma"
});
menuTopScoreTxt.anchor.set(1, 0);
menuTopScoreTxt.x = 2048 - 40;
menuTopScoreTxt.y = 40;
mainMenu.addChild(menuTopScoreTxt);
// Show main menu at start
game.addChild(mainMenu);
// Play button event
playBtn.down = function (x, y, obj) {
isGameStarted = true;
mainMenu.visible = false;
// Reset game state
resetGame();
};
// Helper to update menu top score
function updateMenuTopScore(val) {
menuTopScoreTxt.setText('Top Score: ' + val);
}
// --- GUI Elements ---
// Score text
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// High score (best combo) text
var bestComboTxt = new Text2('Best: 0', {
size: 120,
fill: "#000",
font: "bold 900 120px Arial, 'GillSans-Bold', Impact, 'Arial Black', Tahoma"
});
bestComboTxt.anchor.set(1, 0); // right edge, top
bestComboTxt.x = 0; // x=0 in LK.gui.topRight is the right edge
bestComboTxt.y = 0;
LK.gui.topRight.addChild(bestComboTxt);
// Missed fruits indicator (bottom left, red X's)
var missedTxt = new Text2('', {
size: 90,
fill: 0xFF4444
});
missedTxt.anchor.set(0, 1);
LK.gui.bottomLeft.addChild(missedTxt);
// Combo text (center, fades out)
var comboTxt = new Text2('', {
size: 180,
fill: 0xFFE066
});
comboTxt.anchor.set(0.5, 0.5);
comboTxt.alpha = 0;
LK.gui.center.addChild(comboTxt);
// Background switch button (bottom right)
var bgBtn = LK.getAsset('bgBtn', {
anchorX: 1,
anchorY: 1,
width: 180,
height: 100,
color: 0x8888ff,
shape: 'box'
});
bgBtn.x = 0;
bgBtn.y = 0;
LK.gui.bottomRight.addChild(bgBtn);
var bgBtnTxt = new Text2('BG', {
size: 60,
fill: "#fff"
});
bgBtnTxt.anchor.set(0.5, 0.5);
bgBtnTxt.x = -90;
bgBtnTxt.y = -50;
LK.gui.bottomRight.addChild(bgBtnTxt);
// --- BACKGROUND ---
// Fullscreen background image node
var bgImageNode = LK.getAsset('bg4', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
game.addChild(bgImageNode);
function setBackground(idx) {
backgroundIndex = idx % backgrounds.length;
// Always keep background image behind everything
if (bgImageNode.parent) {
game.setChildIndex(bgImageNode, 0);
}
// Optionally, you could swap image asset here if you want to support more backgrounds
game.setBackgroundColor(backgrounds[backgroundIndex].color);
}
setBackground(0);
// --- FRUIT & BOMB SPAWNING ---
function spawnFruitOrBomb() {
// Randomly decide: 80% fruit, 20% bomb
var isBomb = Math.random() < 0.2;
var obj;
// Spawn X within safe bounds
var x = 320 + Math.random() * (2048 - 640);
var y = 2732 + 80;
// Calculate angle so fruit always arcs toward center
var centerX = 2048 / 2;
var dx = centerX - x;
var minAngle = -Math.PI / 2 - Math.PI / 6; // -120deg
var maxAngle = -Math.PI / 2 + Math.PI / 6; // -60deg
// Angle toward center, with a little random spread
var baseAngle = Math.atan2(-1200, dx);
var angle = baseAngle + (Math.random() - 0.5) * (Math.PI / 12); // small random spread
// Clamp angle to safe range
if (angle < minAngle) angle = minAngle;
if (angle > maxAngle) angle = maxAngle;
var speed = 38 + Math.random() * 10;
if (isBomb) {
obj = new Bomb();
bombs.push(obj);
} else {
obj = new Fruit();
fruits.push(obj);
}
obj.x = x;
obj.y = y;
obj.vx = Math.cos(angle) * speed;
obj.vy = Math.sin(angle) * speed;
game.addChild(obj);
}
// --- GAME LOGIC ---
// Slicing logic: track swipe path and check for intersection
var swipePath = [];
var swipeMaxLength = 8; // Only keep last 8 points
// Hide gameplay GUI until game starts
scoreTxt.visible = false;
bestComboTxt.visible = false;
missedTxt.visible = false;
comboTxt.visible = false;
bgBtn.visible = false;
bgBtnTxt.visible = false;
// Show/hide GUI based on game state
function updateGUIVisibility() {
var show = isGameStarted;
scoreTxt.visible = show;
bestComboTxt.visible = show;
missedTxt.visible = show;
comboTxt.visible = show;
bgBtn.visible = show;
bgBtnTxt.visible = show;
}
// Call this after Play is pressed
function startGame() {
isGameStarted = true;
mainMenu.visible = false;
updateGUIVisibility();
resetGame();
}
// Overwrite playBtn.down to use startGame
playBtn.down = function (x, y, obj) {
startGame();
};
function handleSlice(x, y) {
if (!isGameStarted) return;
// Check fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (fruit.sliced) continue;
// If swipe is close to fruit center (distance < 120)
var dx = fruit.x - x;
var dy = fruit.y - y;
if (dx * dx + dy * dy < 120 * 120) {
fruit.slice();
// Combo logic
if (lastSliceTick > 0 && LK.ticks - lastSliceTick < comboWindow) {
comboCount++;
} else {
comboCount = 1;
}
lastSliceTick = LK.ticks;
// Combo multiplier: 1x for single, 2x for double, 3x for triple or more
var comboMultiplier = 1;
if (comboCount === 2) comboMultiplier = 2;
if (comboCount >= 3) comboMultiplier = 3;
// Each fruit is worth 10 points, multiplied by combo
var pointsEarned = 10 * comboMultiplier;
LK.setScore(LK.getScore() + pointsEarned);
scoreTxt.setText(LK.getScore());
// Show combo text if comboCount >= 2
if (comboCount >= 2) {
showCombo(comboCount);
}
// Track best combo
if (typeof bestCombo === "undefined") {
bestCombo = 0;
}
if (comboCount > bestCombo) {
bestCombo = comboCount;
bestComboTxt.setText('Best: ' + bestCombo);
}
fruit.sliceTick = LK.ticks;
}
}
// Check bombs
for (var j = bombs.length - 1; j >= 0; j--) {
var bomb = bombs[j];
if (bomb.sliced) continue;
var dx = bomb.x - x;
var dy = bomb.y - y;
if (dx * dx + dy * dy < 120 * 120) {
bomb.slice();
// Game over
LK.effects.flashScreen(0xff0000, 800);
LK.showGameOver();
return;
}
}
}
// Show combo text
function showCombo(count) {
if (count < 2) return;
comboTxt.setText('Combo x' + count + '!');
comboTxt.alpha = 1;
comboTxt.scaleX = 1.8;
comboTxt.scaleY = 1.8;
comboTxt.fill = "#FFD700"; // Gold color for extra flash
// Animate: scale down, fade out, and color back to yellow
tween(comboTxt, {
scaleX: 1,
scaleY: 1,
alpha: 0,
fill: 0xFFE066
}, {
duration: 900,
easing: tween.easeOut,
onUpdate: function onUpdate() {
// Defensive: ensure fill is always a string
if (typeof comboTxt.fill !== "string") comboTxt.fill = "#FFE066";
}
});
}
// Update missed fruits display
function updateMissed() {
var s = '';
for (var i = 0; i < missedFruits; i++) s += '✗ ';
missedTxt.setText(s);
}
// --- INPUT HANDLING ---
// Swiping: track move events, draw path, and slice
game.move = function (x, y, obj) {
if (!isGameStarted) return;
// Don't allow swipes in top left 100x100
if (x < 100 && y < 100) return;
// Add to swipe path
swipePath.push({
x: x,
y: y,
tick: LK.ticks
});
if (swipePath.length > swipeMaxLength) swipePath.shift();
// For each point in swipe path, check for slicing
for (var i = 0; i < swipePath.length; i++) {
handleSlice(swipePath[i].x, swipePath[i].y);
}
};
// On down, start new swipe
game.down = function (x, y, obj) {
if (!isGameStarted) return;
swipePath = [{
x: x,
y: y,
tick: LK.ticks
}];
handleSlice(x, y);
};
// On up, clear swipe path
game.up = function (x, y, obj) {
if (!isGameStarted) return;
swipePath = [];
};
// Background button: tap to change background
bgBtn.down = function (x, y, obj) {
setBackground((backgroundIndex + 1) % backgrounds.length);
};
// --- GAME UPDATE LOOP ---
game.update = function () {
if (!isGameStarted) {
updateGUIVisibility();
return;
}
updateGUIVisibility();
// Spawn fruits/bombs every 35-55 ticks
if (LK.ticks % (35 + Math.floor(Math.random() * 20)) === 0) {
spawnFruitOrBomb();
}
// Update fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Remove if destroyed
if (fruit.destroyed) {
fruits.splice(i, 1);
continue;
}
// If missed
if (fruit.missed && !fruit.sliced) {
fruits.splice(i, 1);
missedFruits++;
updateMissed();
LK.effects.flashObject(missedTxt, 0xff0000, 400);
if (missedFruits >= maxMissed) {
LK.effects.flashScreen(0xff0000, 800);
LK.showGameOver();
return;
}
}
}
// Update bombs
for (var j = bombs.length - 1; j >= 0; j--) {
var bomb = bombs[j];
if (bomb.destroyed) {
bombs.splice(j, 1);
continue;
}
}
// Combo reset
if (comboCount > 1 && LK.ticks - lastSliceTick > comboWindow) {
comboCount = 0;
}
};
// --- GAME RESET HANDLING ---
// On game reset, clear all arrays and reset state
function resetGame() {
fruits = [];
bombs = [];
missedFruits = 0;
comboCount = 0;
lastSliceTick = -100;
scoreTxt.setText('0');
comboTxt.setText('');
comboTxt.alpha = 0;
updateMissed();
setBackground(0);
// Only reset bestCombo if not started, otherwise keep best score
if (!isGameStarted) {
bestCombo = 0;
bestComboTxt.setText('Best: 0');
updateMenuTopScore(0);
} else {
bestComboTxt.setText('Best: ' + (typeof bestCombo !== "undefined" ? bestCombo : 0));
updateMenuTopScore(typeof bestCombo !== "undefined" ? bestCombo : 0);
}
}
resetGame();
// --- END OF GAME CODE ---
bomb. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a chopping board with a kitchen background. In-Game asset. 2d. High contrast. No shadows
üzerinde by furkan yazan bir yazı. In-Game asset. 2d. High contrast. No shadows
double katana. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
applea. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
exploe. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
red. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Tap to play button . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat