User prompt
fruit_purple hız efekti gitdikdennsonra fruit_cyan da silinsin
User prompt
fruit_purple kesildikden sonra fruit_cyan gelsinn ekranı kaplasın
User prompt
fruit_cyan meyve gibi gelmesin sadece fruit_purple kesildikten sonra bütün ekranı kaplayaram gelsin
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'sliced')' in or related to this line: 'if (f.sliced) {' Line Number: 807
User prompt
fruit_purple kesdikden sonra fruit cyan gelsin ekranın tamamın tutsun
User prompt
yeni asset ekle
User prompt
fruit_blue kesilince "-1 bomb" yazsın
User prompt
fruit_blue kesilince kesdiğimiz bomba hakklarından birisi gitsin ve erra
User prompt
yeni asset ekle
User prompt
meyvelerin hızın azalt
User prompt
put the second meter on the top right of the screen
User prompt
when we press and hold the place where we touch, a line will appear where we touch
User prompt
every time you get a 0 at the end, let me know the number you've reached.
User prompt
let you know every time you get a 0 at the end.
User prompt
Let slice_trail be a straight line
User prompt
When the fruit_pruple is interrupted, the fruits slow down and a blue effect appears on the edges of the screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
we have the right to hit the bomb three times.
User prompt
when the objects are cut, the screen vibrates a little and the parts of the objects separate ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
enlarge objects by 20 percent
User prompt
delete the effect when touching and replace it with an effect similar to a knife cut
User prompt
delete the effect when touching and replace it with an effect similar to a knife cut
User prompt
Make the objects bigger and cut them with a knife, make it like a white line and cut the objects in half from where they were cut. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make objects bigger
Code edit (1 edits merged)
Please save this source code
User prompt
Fruit Slice Frenzy
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Bomb class
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.asset = self.attachAsset('bomb', {
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.update = function () {
if (self.sliced) return;
self.x += self.vx;
self.y += self.vy;
self.vy += self.gravity;
// Off screen: bottom
if (self.y > 2732 + 100) {
self.destroy();
for (var i = bombs.length - 1; i >= 0; i--) {
if (bombs[i] === self) {
bombs.splice(i, 1);
break;
}
}
}
};
self.slice = function () {
if (self.sliced) return false;
self.sliced = true;
// Animate bomb
tween(self, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 250,
onFinish: function onFinish() {
self.destroy();
}
});
for (var i = bombs.length - 1; i >= 0; i--) {
if (bombs[i] === self) {
bombs.splice(i, 1);
break;
}
}
return true;
};
return self;
});
// Fruit class
var Fruit = Container.expand(function () {
var self = Container.call(this);
// Fruit type: {id, color, points}
self.fruitType = null;
// Attach asset
self.asset = null;
// Physics
self.vx = 0;
self.vy = 0;
self.gravity = 0.35 + Math.random() * 0.1;
// Sliced state
self.sliced = false;
// For combo detection
self.sliceId = null;
// Set fruit type and asset
self.setType = function (type) {
self.fruitType = type;
self.asset = self.attachAsset(type.id, {
anchorX: 0.5,
anchorY: 0.5
});
};
// Called every tick
self.update = function () {
if (self.sliced) return;
self.x += self.vx;
self.y += self.vy;
self.vy += self.gravity;
// Off screen: bottom
if (self.y > 2732 + 100) {
self.destroy();
// Remove from fruits array in main game
for (var i = fruits.length - 1; i >= 0; i--) {
if (fruits[i] === self) {
fruits.splice(i, 1);
break;
}
}
}
};
// Slice the fruit
self.slice = function (sliceId) {
if (self.sliced) return false;
self.sliced = true;
self.sliceId = sliceId;
// Splat effect
var splat = LK.getAsset('splat', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y
});
splat.tint = self.fruitType.color;
game.addChild(splat);
tween(splat, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
splat.destroy();
}
});
// Animate fruit disappearing
tween(self, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 250,
onFinish: function onFinish() {
self.destroy();
}
});
// Remove from fruits array in main game
for (var i = fruits.length - 1; i >= 0; i--) {
if (fruits[i] === self) {
fruits.splice(i, 1);
break;
}
}
return true;
};
// Slice bomb (should not be called, but for safety)
self.sliceBomb = function () {
if (self.sliced) return false;
self.sliced = true;
tween(self, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 250,
onFinish: function onFinish() {
self.destroy();
}
});
for (var i = fruits.length - 1; i >= 0; i--) {
if (fruits[i] === self) {
fruits.splice(i, 1);
break;
}
}
return true;
};
return self;
});
// Slice trail class
var SliceTrail = Container.expand(function () {
var self = Container.call(this);
self.asset = self.attachAsset('slice_trail', {
anchorX: 0.5,
anchorY: 0.5
});
self.asset.alpha = 0.5;
self.asset.scaleX = 1.2;
self.asset.scaleY = 0.5;
self.life = 18; // frames
self.update = function () {
self.life--;
self.asset.alpha *= 0.85;
if (self.life <= 0) {
self.destroy();
for (var i = sliceTrails.length - 1; i >= 0; i--) {
if (sliceTrails[i] === self) {
sliceTrails.splice(i, 1);
break;
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
// Music
// Sound effects
// Splat effect
// Slice trail
// Bomb shape
// Watermelon
// Plum
// Orange
// Kiwi
// Lemon
// Apple
// Fruit shapes (different colors for different fruits)
// Fruit types
var fruitTypes = [{
id: 'fruit_red',
color: 0xff3b3b,
points: 1
}, {
id: 'fruit_yellow',
color: 0xffe14d,
points: 1
}, {
id: 'fruit_green',
color: 0x6be14d,
points: 1
}, {
id: 'fruit_orange',
color: 0xffa500,
points: 1
}, {
id: 'fruit_purple',
color: 0xb84dff,
points: 1
}, {
id: 'fruit_pink',
color: 0xff4da6,
points: 1
}];
// Game state
var fruits = [];
var bombs = [];
var sliceTrails = [];
var lastSlicePoints = [];
var comboCount = 0;
var comboTimer = 0;
var score = 0;
var timeLeft = 60; // seconds
var gameActive = true;
var lastSpawnTick = 0;
var spawnInterval = 60; // frames
var minSpawnInterval = 24;
var spawnAcceleration = 0.995; // gets faster
var sliceIdCounter = 1;
// Score display
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Timer display
var timerTxt = new Text2('60', {
size: 90,
fill: "#fff"
});
timerTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(timerTxt);
// Combo display
var comboTxt = new Text2('', {
size: 100,
fill: 0xFFE14D
});
comboTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(comboTxt);
// Start music
LK.playMusic('bgmusic');
// Timer
var timerInterval = LK.setInterval(function () {
if (!gameActive) return;
timeLeft--;
if (timeLeft < 0) timeLeft = 0;
timerTxt.setText(timeLeft);
if (timeLeft <= 0) {
gameActive = false;
LK.showGameOver();
}
}, 1000);
// Helper: spawn a fruit at a random position with random velocity
function spawnFruit() {
var fruit = new Fruit();
var type = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
fruit.setType(type);
// Spawn from bottom, random X (avoid edges)
var margin = 180;
fruit.x = margin + Math.random() * (2048 - 2 * margin);
fruit.y = 2732 + 60;
// Arc velocity: up and sideways
var angle = -Math.PI / 2 + (Math.random() - 0.5) * Math.PI / 3; // mostly up
var speed = 38 + Math.random() * 10;
fruit.vx = Math.cos(angle) * speed;
fruit.vy = Math.sin(angle) * speed;
fruit.scaleX = fruit.scaleY = 1 + (Math.random() - 0.5) * 0.2;
fruits.push(fruit);
game.addChild(fruit);
}
// Helper: spawn a bomb
function spawnBomb() {
var bomb = new Bomb();
var margin = 180;
bomb.x = margin + Math.random() * (2048 - 2 * margin);
bomb.y = 2732 + 60;
var angle = -Math.PI / 2 + (Math.random() - 0.5) * Math.PI / 3;
var speed = 36 + Math.random() * 8;
bomb.vx = Math.cos(angle) * speed;
bomb.vy = Math.sin(angle) * speed;
bomb.scaleX = bomb.scaleY = 1 + (Math.random() - 0.5) * 0.2;
bombs.push(bomb);
game.addChild(bomb);
}
// Helper: spawn a wave (fruits + maybe bomb)
function spawnWave() {
var n = 2 + Math.floor(Math.random() * 3); // 2-4 fruits
for (var i = 0; i < n; i++) {
spawnFruit();
}
// 1 in 3 chance of bomb
if (Math.random() < 0.33) {
spawnBomb();
}
}
// Helper: check if a line segment (x1,y1)-(x2,y2) intersects a circle (cx,cy,r)
function lineCircleIntersect(x1, y1, x2, y2, cx, cy, r) {
// Closest point on line to circle center
var dx = x2 - x1,
dy = y2 - y1;
var fx = x1 - cx,
fy = y1 - cy;
var a = dx * dx + dy * dy;
var b = 2 * (fx * dx + fy * dy);
var c = fx * fx + fy * fy - r * r;
var discriminant = b * b - 4 * a * c;
if (discriminant < 0) return false;
discriminant = Math.sqrt(discriminant);
var t1 = (-b - discriminant) / (2 * a);
var t2 = (-b + discriminant) / (2 * a);
if (t1 >= 0 && t1 <= 1 || t2 >= 0 && t2 <= 1) return true;
return false;
}
// Helper: show combo text
function showCombo(count, x, y) {
if (count < 2) return;
comboTxt.setText('Combo x' + count + '!');
comboTxt.x = 0;
comboTxt.y = 0;
comboTxt.alpha = 1;
tween(comboTxt, {
alpha: 0
}, {
duration: 900,
onFinish: function onFinish() {
comboTxt.setText('');
}
});
LK.getSound('combo').play();
}
// Touch/mouse slice tracking
var isSlicing = false;
var slicePoints = [];
var lastSliceTime = 0;
// Don't allow slices to start in top left 100x100 (menu area)
function isInMenuArea(x, y) {
return x < 100 && y < 100;
}
// Main move handler
function handleMove(x, y, obj) {
if (!gameActive) return;
if (!isSlicing) return;
// Clamp to game area
if (x < 0) x = 0;
if (x > 2048) x = 2048;
if (y < 0) y = 0;
if (y > 2732) y = 2732;
// Add to slice points
slicePoints.push({
x: x,
y: y,
t: LK.ticks
});
// Only keep last 8 points
if (slicePoints.length > 8) slicePoints.shift();
// Draw slice trail
var trail = new SliceTrail();
trail.x = x;
trail.y = y;
sliceTrails.push(trail);
game.addChild(trail);
// Only check for slicing if moved enough
if (slicePoints.length >= 2) {
var p1 = slicePoints[slicePoints.length - 2];
var p2 = slicePoints[slicePoints.length - 1];
var slicedThisMove = [];
var sliceId = sliceIdCounter++;
// Check fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var f = fruits[i];
if (f.sliced) continue;
var r = f.asset.width * 0.5 * 0.95;
if (lineCircleIntersect(p1.x, p1.y, p2.x, p2.y, f.x, f.y, r)) {
if (f.slice(sliceId)) {
slicedThisMove.push(f);
LK.getSound('slice').play();
// Score
score += f.fruitType.points;
LK.setScore(score);
scoreTxt.setText(score);
}
}
}
// Check bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var b = bombs[i];
if (b.sliced) continue;
var r = b.asset.width * 0.5 * 0.95;
if (lineCircleIntersect(p1.x, p1.y, p2.x, p2.y, b.x, b.y, r)) {
b.slice();
LK.getSound('bomb').play();
// Flash screen
LK.effects.flashScreen(0xff0000, 900);
gameActive = false;
LK.showGameOver();
return;
}
}
// Combo detection
if (slicedThisMove.length > 1) {
showCombo(slicedThisMove.length, x, y);
score += (slicedThisMove.length - 1) * 2; // bonus
LK.setScore(score);
scoreTxt.setText(score);
}
}
}
// Down event: start slicing
game.down = function (x, y, obj) {
if (!gameActive) return;
if (isInMenuArea(x, y)) return;
isSlicing = true;
slicePoints = [{
x: x,
y: y,
t: LK.ticks
}];
// Draw trail
var trail = new SliceTrail();
trail.x = x;
trail.y = y;
sliceTrails.push(trail);
game.addChild(trail);
};
// Up event: end slicing
game.up = function (x, y, obj) {
isSlicing = false;
slicePoints = [];
};
// Move event
game.move = handleMove;
// Main update loop
game.update = function () {
if (!gameActive) return;
// Update all fruits, bombs, slice trails
for (var i = fruits.length - 1; i >= 0; i--) {
if (fruits[i].update) fruits[i].update();
}
for (var i = bombs.length - 1; i >= 0; i--) {
if (bombs[i].update) bombs[i].update();
}
for (var i = sliceTrails.length - 1; i >= 0; i--) {
if (sliceTrails[i].update) sliceTrails[i].update();
}
// Spawn new wave
if (LK.ticks - lastSpawnTick > spawnInterval) {
spawnWave();
lastSpawnTick = LK.ticks;
spawnInterval = Math.max(minSpawnInterval, Math.floor(spawnInterval * spawnAcceleration));
}
};
// Clean up on game over
function cleanup() {
for (var i = fruits.length - 1; i >= 0; i--) {
fruits[i].destroy();
}
fruits = [];
for (var i = bombs.length - 1; i >= 0; i--) {
bombs[i].destroy();
}
bombs = [];
for (var i = sliceTrails.length - 1; i >= 0; i--) {
sliceTrails[i].destroy();
}
sliceTrails = [];
comboTxt.setText('');
isSlicing = false;
slicePoints = [];
}
// Listen for game over to clean up
LK.on('gameover', function () {
cleanup();
LK.clearInterval(timerInterval);
LK.stopMusic();
});
// Listen for you win (if you want to add a win condition in future)
LK.on('youwin', function () {
cleanup();
LK.clearInterval(timerInterval);
LK.stopMusic();
}); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,523 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Bomb class
+var Bomb = Container.expand(function () {
+ var self = Container.call(this);
+ self.asset = self.attachAsset('bomb', {
+ 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.update = function () {
+ if (self.sliced) return;
+ self.x += self.vx;
+ self.y += self.vy;
+ self.vy += self.gravity;
+ // Off screen: bottom
+ if (self.y > 2732 + 100) {
+ self.destroy();
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ if (bombs[i] === self) {
+ bombs.splice(i, 1);
+ break;
+ }
+ }
+ }
+ };
+ self.slice = function () {
+ if (self.sliced) return false;
+ self.sliced = true;
+ // Animate bomb
+ tween(self, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 250,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ if (bombs[i] === self) {
+ bombs.splice(i, 1);
+ break;
+ }
+ }
+ return true;
+ };
+ return self;
+});
+// Fruit class
+var Fruit = Container.expand(function () {
+ var self = Container.call(this);
+ // Fruit type: {id, color, points}
+ self.fruitType = null;
+ // Attach asset
+ self.asset = null;
+ // Physics
+ self.vx = 0;
+ self.vy = 0;
+ self.gravity = 0.35 + Math.random() * 0.1;
+ // Sliced state
+ self.sliced = false;
+ // For combo detection
+ self.sliceId = null;
+ // Set fruit type and asset
+ self.setType = function (type) {
+ self.fruitType = type;
+ self.asset = self.attachAsset(type.id, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ };
+ // Called every tick
+ self.update = function () {
+ if (self.sliced) return;
+ self.x += self.vx;
+ self.y += self.vy;
+ self.vy += self.gravity;
+ // Off screen: bottom
+ if (self.y > 2732 + 100) {
+ self.destroy();
+ // Remove from fruits array in main game
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ if (fruits[i] === self) {
+ fruits.splice(i, 1);
+ break;
+ }
+ }
+ }
+ };
+ // Slice the fruit
+ self.slice = function (sliceId) {
+ if (self.sliced) return false;
+ self.sliced = true;
+ self.sliceId = sliceId;
+ // Splat effect
+ var splat = LK.getAsset('splat', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: self.x,
+ y: self.y
+ });
+ splat.tint = self.fruitType.color;
+ game.addChild(splat);
+ tween(splat, {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ splat.destroy();
+ }
+ });
+ // Animate fruit disappearing
+ tween(self, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 250,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ // Remove from fruits array in main game
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ if (fruits[i] === self) {
+ fruits.splice(i, 1);
+ break;
+ }
+ }
+ return true;
+ };
+ // Slice bomb (should not be called, but for safety)
+ self.sliceBomb = function () {
+ if (self.sliced) return false;
+ self.sliced = true;
+ tween(self, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 250,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ if (fruits[i] === self) {
+ fruits.splice(i, 1);
+ break;
+ }
+ }
+ return true;
+ };
+ return self;
+});
+// Slice trail class
+var SliceTrail = Container.expand(function () {
+ var self = Container.call(this);
+ self.asset = self.attachAsset('slice_trail', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.asset.alpha = 0.5;
+ self.asset.scaleX = 1.2;
+ self.asset.scaleY = 0.5;
+ self.life = 18; // frames
+ self.update = function () {
+ self.life--;
+ self.asset.alpha *= 0.85;
+ if (self.life <= 0) {
+ self.destroy();
+ for (var i = sliceTrails.length - 1; i >= 0; i--) {
+ if (sliceTrails[i] === self) {
+ sliceTrails.splice(i, 1);
+ break;
+ }
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
+ backgroundColor: 0x1a1a1a
+});
+
+/****
+* Game Code
+****/
+// Music
+// Sound effects
+// Splat effect
+// Slice trail
+// Bomb shape
+// Watermelon
+// Plum
+// Orange
+// Kiwi
+// Lemon
+// Apple
+// Fruit shapes (different colors for different fruits)
+// Fruit types
+var fruitTypes = [{
+ id: 'fruit_red',
+ color: 0xff3b3b,
+ points: 1
+}, {
+ id: 'fruit_yellow',
+ color: 0xffe14d,
+ points: 1
+}, {
+ id: 'fruit_green',
+ color: 0x6be14d,
+ points: 1
+}, {
+ id: 'fruit_orange',
+ color: 0xffa500,
+ points: 1
+}, {
+ id: 'fruit_purple',
+ color: 0xb84dff,
+ points: 1
+}, {
+ id: 'fruit_pink',
+ color: 0xff4da6,
+ points: 1
+}];
+// Game state
+var fruits = [];
+var bombs = [];
+var sliceTrails = [];
+var lastSlicePoints = [];
+var comboCount = 0;
+var comboTimer = 0;
+var score = 0;
+var timeLeft = 60; // seconds
+var gameActive = true;
+var lastSpawnTick = 0;
+var spawnInterval = 60; // frames
+var minSpawnInterval = 24;
+var spawnAcceleration = 0.995; // gets faster
+var sliceIdCounter = 1;
+// Score display
+var scoreTxt = new Text2('0', {
+ size: 120,
+ fill: "#fff"
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Timer display
+var timerTxt = new Text2('60', {
+ size: 90,
+ fill: "#fff"
+});
+timerTxt.anchor.set(0.5, 0);
+LK.gui.topRight.addChild(timerTxt);
+// Combo display
+var comboTxt = new Text2('', {
+ size: 100,
+ fill: 0xFFE14D
+});
+comboTxt.anchor.set(0.5, 0.5);
+LK.gui.center.addChild(comboTxt);
+// Start music
+LK.playMusic('bgmusic');
+// Timer
+var timerInterval = LK.setInterval(function () {
+ if (!gameActive) return;
+ timeLeft--;
+ if (timeLeft < 0) timeLeft = 0;
+ timerTxt.setText(timeLeft);
+ if (timeLeft <= 0) {
+ gameActive = false;
+ LK.showGameOver();
+ }
+}, 1000);
+// Helper: spawn a fruit at a random position with random velocity
+function spawnFruit() {
+ var fruit = new Fruit();
+ var type = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
+ fruit.setType(type);
+ // Spawn from bottom, random X (avoid edges)
+ var margin = 180;
+ fruit.x = margin + Math.random() * (2048 - 2 * margin);
+ fruit.y = 2732 + 60;
+ // Arc velocity: up and sideways
+ var angle = -Math.PI / 2 + (Math.random() - 0.5) * Math.PI / 3; // mostly up
+ var speed = 38 + Math.random() * 10;
+ fruit.vx = Math.cos(angle) * speed;
+ fruit.vy = Math.sin(angle) * speed;
+ fruit.scaleX = fruit.scaleY = 1 + (Math.random() - 0.5) * 0.2;
+ fruits.push(fruit);
+ game.addChild(fruit);
+}
+// Helper: spawn a bomb
+function spawnBomb() {
+ var bomb = new Bomb();
+ var margin = 180;
+ bomb.x = margin + Math.random() * (2048 - 2 * margin);
+ bomb.y = 2732 + 60;
+ var angle = -Math.PI / 2 + (Math.random() - 0.5) * Math.PI / 3;
+ var speed = 36 + Math.random() * 8;
+ bomb.vx = Math.cos(angle) * speed;
+ bomb.vy = Math.sin(angle) * speed;
+ bomb.scaleX = bomb.scaleY = 1 + (Math.random() - 0.5) * 0.2;
+ bombs.push(bomb);
+ game.addChild(bomb);
+}
+// Helper: spawn a wave (fruits + maybe bomb)
+function spawnWave() {
+ var n = 2 + Math.floor(Math.random() * 3); // 2-4 fruits
+ for (var i = 0; i < n; i++) {
+ spawnFruit();
+ }
+ // 1 in 3 chance of bomb
+ if (Math.random() < 0.33) {
+ spawnBomb();
+ }
+}
+// Helper: check if a line segment (x1,y1)-(x2,y2) intersects a circle (cx,cy,r)
+function lineCircleIntersect(x1, y1, x2, y2, cx, cy, r) {
+ // Closest point on line to circle center
+ var dx = x2 - x1,
+ dy = y2 - y1;
+ var fx = x1 - cx,
+ fy = y1 - cy;
+ var a = dx * dx + dy * dy;
+ var b = 2 * (fx * dx + fy * dy);
+ var c = fx * fx + fy * fy - r * r;
+ var discriminant = b * b - 4 * a * c;
+ if (discriminant < 0) return false;
+ discriminant = Math.sqrt(discriminant);
+ var t1 = (-b - discriminant) / (2 * a);
+ var t2 = (-b + discriminant) / (2 * a);
+ if (t1 >= 0 && t1 <= 1 || t2 >= 0 && t2 <= 1) return true;
+ return false;
+}
+// Helper: show combo text
+function showCombo(count, x, y) {
+ if (count < 2) return;
+ comboTxt.setText('Combo x' + count + '!');
+ comboTxt.x = 0;
+ comboTxt.y = 0;
+ comboTxt.alpha = 1;
+ tween(comboTxt, {
+ alpha: 0
+ }, {
+ duration: 900,
+ onFinish: function onFinish() {
+ comboTxt.setText('');
+ }
+ });
+ LK.getSound('combo').play();
+}
+// Touch/mouse slice tracking
+var isSlicing = false;
+var slicePoints = [];
+var lastSliceTime = 0;
+// Don't allow slices to start in top left 100x100 (menu area)
+function isInMenuArea(x, y) {
+ return x < 100 && y < 100;
+}
+// Main move handler
+function handleMove(x, y, obj) {
+ if (!gameActive) return;
+ if (!isSlicing) return;
+ // Clamp to game area
+ if (x < 0) x = 0;
+ if (x > 2048) x = 2048;
+ if (y < 0) y = 0;
+ if (y > 2732) y = 2732;
+ // Add to slice points
+ slicePoints.push({
+ x: x,
+ y: y,
+ t: LK.ticks
+ });
+ // Only keep last 8 points
+ if (slicePoints.length > 8) slicePoints.shift();
+ // Draw slice trail
+ var trail = new SliceTrail();
+ trail.x = x;
+ trail.y = y;
+ sliceTrails.push(trail);
+ game.addChild(trail);
+ // Only check for slicing if moved enough
+ if (slicePoints.length >= 2) {
+ var p1 = slicePoints[slicePoints.length - 2];
+ var p2 = slicePoints[slicePoints.length - 1];
+ var slicedThisMove = [];
+ var sliceId = sliceIdCounter++;
+ // Check fruits
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ var f = fruits[i];
+ if (f.sliced) continue;
+ var r = f.asset.width * 0.5 * 0.95;
+ if (lineCircleIntersect(p1.x, p1.y, p2.x, p2.y, f.x, f.y, r)) {
+ if (f.slice(sliceId)) {
+ slicedThisMove.push(f);
+ LK.getSound('slice').play();
+ // Score
+ score += f.fruitType.points;
+ LK.setScore(score);
+ scoreTxt.setText(score);
+ }
+ }
+ }
+ // Check bombs
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ var b = bombs[i];
+ if (b.sliced) continue;
+ var r = b.asset.width * 0.5 * 0.95;
+ if (lineCircleIntersect(p1.x, p1.y, p2.x, p2.y, b.x, b.y, r)) {
+ b.slice();
+ LK.getSound('bomb').play();
+ // Flash screen
+ LK.effects.flashScreen(0xff0000, 900);
+ gameActive = false;
+ LK.showGameOver();
+ return;
+ }
+ }
+ // Combo detection
+ if (slicedThisMove.length > 1) {
+ showCombo(slicedThisMove.length, x, y);
+ score += (slicedThisMove.length - 1) * 2; // bonus
+ LK.setScore(score);
+ scoreTxt.setText(score);
+ }
+ }
+}
+// Down event: start slicing
+game.down = function (x, y, obj) {
+ if (!gameActive) return;
+ if (isInMenuArea(x, y)) return;
+ isSlicing = true;
+ slicePoints = [{
+ x: x,
+ y: y,
+ t: LK.ticks
+ }];
+ // Draw trail
+ var trail = new SliceTrail();
+ trail.x = x;
+ trail.y = y;
+ sliceTrails.push(trail);
+ game.addChild(trail);
+};
+// Up event: end slicing
+game.up = function (x, y, obj) {
+ isSlicing = false;
+ slicePoints = [];
+};
+// Move event
+game.move = handleMove;
+// Main update loop
+game.update = function () {
+ if (!gameActive) return;
+ // Update all fruits, bombs, slice trails
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ if (fruits[i].update) fruits[i].update();
+ }
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ if (bombs[i].update) bombs[i].update();
+ }
+ for (var i = sliceTrails.length - 1; i >= 0; i--) {
+ if (sliceTrails[i].update) sliceTrails[i].update();
+ }
+ // Spawn new wave
+ if (LK.ticks - lastSpawnTick > spawnInterval) {
+ spawnWave();
+ lastSpawnTick = LK.ticks;
+ spawnInterval = Math.max(minSpawnInterval, Math.floor(spawnInterval * spawnAcceleration));
+ }
+};
+// Clean up on game over
+function cleanup() {
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ fruits[i].destroy();
+ }
+ fruits = [];
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ bombs[i].destroy();
+ }
+ bombs = [];
+ for (var i = sliceTrails.length - 1; i >= 0; i--) {
+ sliceTrails[i].destroy();
+ }
+ sliceTrails = [];
+ comboTxt.setText('');
+ isSlicing = false;
+ slicePoints = [];
+}
+// Listen for game over to clean up
+LK.on('gameover', function () {
+ cleanup();
+ LK.clearInterval(timerInterval);
+ LK.stopMusic();
+});
+// Listen for you win (if you want to add a win condition in future)
+LK.on('youwin', function () {
+ cleanup();
+ LK.clearInterval(timerInterval);
+ LK.stopMusic();
});
\ No newline at end of file
red apple. In-Game asset. 2d. High contrast. No shadows
orange. In-Game asset. 2d. High contrast. No shadows
lemon. In-Game asset. 2d. High contrast. No shadows
ice . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
straight and white slash thin at the tip and thick in the middle. In-Game asset. 2d. High contrast. No shadows
banana. In-Game asset. 2d. High contrast. No shadows
+. In-Game asset. 2d. High contrast. No shadows
kenarlardan gelen donma efekti. In-Game asset. 2d. High contrast. No shadows