/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.exploded = false;
self.touched = false;
self.lastY = 0;
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
// Physics properties
self.velocityX = 0; // Will be set during spawn
self.velocityY = 0; // Will be set during spawn
self.gravity = 0.5;
self.update = function () {
if (self.exploded) return;
self.lastY = self.y;
// Apply physics
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
// Slight rotation
bombGraphics.rotation += 0.05;
// Pulsing effect to make it look dangerous
var pulse = Math.sin(LK.ticks * 0.2) * 0.1 + 1;
bombGraphics.scaleX = pulse;
bombGraphics.scaleY = pulse;
// Add horizontal movement for moving bombs
if (self.isMoving) {
self.velocityX = Math.sin(LK.ticks * 0.05) * 8;
}
};
self.explode = function () {
if (self.exploded) return;
self.exploded = true;
// Create explosion effect
LK.effects.flashScreen(0xff0000, 500);
// Create explosion particles
for (var i = 0; i < 8; i++) {
var particle = LK.getAsset('slice_effect', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
tint: 0xff4444,
scaleX: 0.5,
scaleY: 0.5
});
game.addChild(particle);
var angle = i / 8 * Math.PI * 2;
var distance = 150;
var targetX = self.x + Math.cos(angle) * distance;
var targetY = self.y + Math.sin(angle) * distance;
tween(particle, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 600,
easing: tween.easeOut,
onFinish: function onFinish() {
particle.destroy();
}
});
}
LK.getSound('bomb_explode').play();
LK.showGameOver();
self.destroy();
};
return self;
});
var Fruit = Container.expand(function (fruitType) {
var self = Container.call(this);
self.fruitType = fruitType || 'fruit_apple';
self.sliced = false;
self.touched = false;
self.lastY = 0;
var fruitGraphics = self.attachAsset(self.fruitType, {
anchorX: 0.5,
anchorY: 0.5
});
// Physics properties
self.velocityX = 0; // Will be set during spawn
self.velocityY = 0; // Will be set during spawn
self.gravity = 0.5;
self.update = function () {
if (self.sliced) return;
self.lastY = self.y;
// Apply physics
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
// Rotate while flying
fruitGraphics.rotation += 0.1;
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
// Combo system
var currentTime = LK.ticks;
if (currentTime - lastSliceTime < 60) {
// 1 second at 60fps (much shorter window)
combo++;
} else {
combo = 1;
}
lastSliceTime = currentTime;
// Score with combo multiplier
var scoreGain = 10 * combo;
LK.setScore(LK.getScore() + scoreGain);
// Create slice effect
var sliceEffect = LK.getAsset('slice_effect', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
alpha: 0.8
});
game.addChild(sliceEffect);
// Animate slice effect
tween(sliceEffect, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
sliceEffect.destroy();
}
});
// Split fruit into two halves using separate sliced assets
var leftHalf = LK.getAsset(self.fruitType + '_left', {
anchorX: 1.0,
anchorY: 0.5,
x: self.x,
y: self.y
});
var rightHalf = LK.getAsset(self.fruitType + '_right', {
anchorX: 0.0,
anchorY: 0.5,
x: self.x,
y: self.y
});
game.addChild(leftHalf);
game.addChild(rightHalf);
// Animate left half falling quickly with rotation
tween(leftHalf, {
y: 3000,
x: leftHalf.x - 100,
rotation: Math.PI * 2
}, {
duration: 1000,
easing: tween.easeIn,
onFinish: function onFinish() {
leftHalf.destroy();
}
});
// Animate right half falling quickly with rotation
tween(rightHalf, {
y: 3000,
x: rightHalf.x + 100,
rotation: -Math.PI * 2
}, {
duration: 1000,
easing: tween.easeIn,
onFinish: function onFinish() {
rightHalf.destroy();
}
});
LK.getSound('slice').play();
self.destroy();
};
return self;
});
var GoldenFruit = Container.expand(function () {
var self = Container.call(this);
self.sliced = false;
self.touched = false;
self.lastY = 0;
self.timeLimit = 120; // 2 seconds at 60fps
self.timeLeft = self.timeLimit;
var fruitGraphics = self.attachAsset('fruit_apple', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700 // Golden color
});
// Physics properties
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8; // Falls faster
self.update = function () {
if (self.sliced) return;
self.lastY = self.y;
// Apply physics
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
// Rotate and pulse
fruitGraphics.rotation += 0.15;
var pulse = Math.sin(LK.ticks * 0.3) * 0.1 + 1;
fruitGraphics.scaleX = pulse;
fruitGraphics.scaleY = pulse;
// Decrease time left
self.timeLeft--;
if (self.timeLeft <= 0 && !self.sliced) {
// Missed golden fruit - lose combo
combo = 0;
self.destroy();
}
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
// Big bonus for golden fruit
var scoreGain = 100 + combo * 10;
LK.setScore(LK.getScore() + scoreGain);
// Don't reset combo, add to it
combo += 2;
lastSliceTime = LK.ticks;
// Create golden slice effect
for (var i = 0; i < 10; i++) {
var particle = LK.getAsset('slice_effect', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
tint: 0xFFD700,
scaleX: 0.3,
scaleY: 0.3
});
game.addChild(particle);
var angle = i / 10 * Math.PI * 2;
var distance = 200;
var targetX = self.x + Math.cos(angle) * distance;
var targetY = self.y + Math.sin(angle) * distance;
tween(particle, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
particle.destroy();
}
});
}
LK.getSound('slice').play();
self.destroy();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var fruits = [];
var bombs = [];
var goldenFruits = [];
var fruitTypes = ['fruit_apple', 'fruit_orange', 'fruit_banana'];
var spawnTimer = 0;
var spawnDelay = 90; // Spawn every 1.5 seconds at 60fps
var isSlicing = false;
var sliceStartX = 0;
var sliceStartY = 0;
var combo = 0;
var lastSliceTime = 0;
var missedFruits = 0;
var maxMissedFruits = 2; // Only 2 lives instead of 3
var difficultyLevel = 1;
var goldenSpawnTimer = 0;
var movingBombActive = false;
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Combo display
var comboTxt = new Text2('', {
size: 60,
fill: 0xFFFF00
});
comboTxt.anchor.set(0.5, 0);
comboTxt.y = 100;
LK.gui.top.addChild(comboTxt);
// Lives display
var livesTxt = new Text2('Lives: ' + maxMissedFruits, {
size: 60,
fill: 0xFF6666
});
livesTxt.anchor.set(1, 0);
livesTxt.x = -50;
LK.gui.topRight.addChild(livesTxt);
// Mouse/touch handlers for slicing
game.down = function (x, y, obj) {
isSlicing = true;
sliceStartX = x;
sliceStartY = y;
// Fruits can only be sliced by swiping, not by touching
// Check if we touched any bombs directly
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
var dx = x - bomb.x;
var dy = y - bomb.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var bombRadius = bomb.getBounds().width / 2;
if (!bomb.exploded && !bomb.touched && distance < bombRadius) {
bomb.touched = true;
bomb.explode();
bombs.splice(i, 1);
return;
}
}
};
game.move = function (x, y, obj) {
if (!isSlicing) return;
// Check if we're slicing through any fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if touch point is within fruit bounds
var dx = x - fruit.x;
var dy = y - fruit.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var fruitRadius = fruit.getBounds().width / 2;
if (!fruit.sliced && !fruit.touched && distance < fruitRadius) {
fruit.touched = true;
fruit.slice();
fruits.splice(i, 1);
}
}
// Check if we're slicing through golden fruits
for (var i = goldenFruits.length - 1; i >= 0; i--) {
var golden = goldenFruits[i];
var dx = x - golden.x;
var dy = y - golden.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var goldenRadius = golden.getBounds().width / 2;
if (!golden.sliced && !golden.touched && distance < goldenRadius) {
golden.touched = true;
golden.slice();
goldenFruits.splice(i, 1);
}
}
// Check if we're slicing through any bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
var dx = x - bomb.x;
var dy = y - bomb.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var bombRadius = bomb.getBounds().width / 2;
if (!bomb.exploded && !bomb.touched && distance < bombRadius) {
bomb.touched = true;
bomb.explode();
bombs.splice(i, 1);
return;
}
}
};
game.up = function (x, y, obj) {
isSlicing = false;
};
// Main game update
game.update = function () {
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
// Update combo display
if (combo > 1) {
comboTxt.setText('Combo x' + combo);
} else {
comboTxt.setText('');
}
// Update lives display
livesTxt.setText('Lives: ' + (maxMissedFruits - missedFruits));
// Reset combo if too much time passed
if (LK.ticks - lastSliceTime > 90) {
// 1.5 seconds (much shorter window)
combo = 0;
}
// Increase difficulty every 300 points (faster progression)
var newDifficultyLevel = Math.floor(LK.getScore() / 300) + 1;
if (newDifficultyLevel > difficultyLevel) {
difficultyLevel = newDifficultyLevel;
spawnDelay = Math.max(15, 90 - difficultyLevel * 15); // Faster spawn rate
}
// Spawn golden fruits at higher difficulty
goldenSpawnTimer++;
if (difficultyLevel >= 2 && goldenSpawnTimer > 600) {
// Every 10 seconds
goldenSpawnTimer = 0;
var golden = new GoldenFruit();
golden.x = 200 + Math.random() * 1648;
golden.y = 2732 + 50;
golden.velocityY = -45 - Math.random() * 15;
golden.velocityX = (Math.random() - 0.5) * 50;
goldenFruits.push(golden);
game.addChild(golden);
}
// Spawn new objects
spawnTimer++;
if (spawnTimer >= spawnDelay) {
spawnTimer = 0;
// Spawn multiple objects at higher difficulty
var spawnCount = Math.min(5, Math.floor(difficultyLevel / 1.5) + 1); // More objects spawn
for (var s = 0; s < spawnCount; s++) {
// Increase bomb chance with difficulty
var bombChance = Math.min(0.6, 0.25 + difficultyLevel * 0.05); // Higher bomb chance
if (Math.random() > bombChance) {
var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(fruitType);
// Random spawn position: 33% bottom, 33% left, 33% right
var spawnType = Math.random();
if (spawnType < 0.33) {
// Spawn from bottom (higher velocity)
fruit.x = 200 + Math.random() * 1648;
fruit.y = 2732 + 50;
fruit.velocityY = -40 - Math.random() * 20 - difficultyLevel * 2; // Much higher upward velocity that increases with difficulty
fruit.velocityX = (Math.random() - 0.5) * 45; // Add more horizontal velocity for angled trajectory
} else if (spawnType < 0.66) {
// Spawn from left side
fruit.x = -100;
fruit.y = 1800 + Math.random() * 600;
fruit.velocityX = 15 + Math.random() * 10 + difficultyLevel * 2; // Faster rightward velocity
fruit.velocityY = -25 - Math.random() * 15; // Higher upward velocity
} else {
// Spawn from right side
fruit.x = 2148;
fruit.y = 1800 + Math.random() * 600;
fruit.velocityX = -15 - Math.random() * 10 - difficultyLevel * 2; // Faster leftward velocity
fruit.velocityY = -25 - Math.random() * 15; // Higher upward velocity
}
fruits.push(fruit);
game.addChild(fruit);
} else {
var bomb = new Bomb();
// Add moving bombs at higher difficulty
if (difficultyLevel >= 3 && Math.random() < 0.3) {
bomb.isMoving = true;
}
// Random spawn position: 33% bottom, 33% left, 33% right
var spawnType = Math.random();
if (spawnType < 0.33) {
// Spawn from bottom (higher velocity)
bomb.x = 200 + Math.random() * 1648;
bomb.y = 2732 + 50;
bomb.velocityY = -35 - Math.random() * 20 - difficultyLevel * 1.5; // Much higher upward velocity
bomb.velocityX = (Math.random() - 0.5) * 40; // Add more horizontal velocity for angled trajectory
} else if (spawnType < 0.66) {
// Spawn from left side
bomb.x = -100;
bomb.y = 1800 + Math.random() * 600;
bomb.velocityX = 10 + Math.random() * 6; // Rightward velocity
bomb.velocityY = -18 - Math.random() * 8; // Upward velocity
} else {
// Spawn from right side
bomb.x = 2148;
bomb.y = 1800 + Math.random() * 600;
bomb.velocityX = -10 - Math.random() * 6; // Leftward velocity
bomb.velocityY = -18 - Math.random() * 8; // Upward velocity
}
bombs.push(bomb);
game.addChild(bomb);
}
}
}
// Update and clean up fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Remove fruits that fell off screen
if (fruit.y > 2732 + 200) {
if (!fruit.sliced) {
missedFruits++;
combo = 0; // Reset combo on miss
if (missedFruits >= maxMissedFruits) {
LK.showGameOver();
}
}
fruit.destroy();
fruits.splice(i, 1);
}
}
// Update and clean up golden fruits
for (var i = goldenFruits.length - 1; i >= 0; i--) {
var golden = goldenFruits[i];
// Remove golden fruits that fell off screen or timed out
if (golden.y > 2732 + 200 || golden.timeLeft <= 0) {
golden.destroy();
goldenFruits.splice(i, 1);
}
}
// Update and clean up bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
// Remove bombs that fell off screen
if (bomb.y > 2732 + 200) {
bomb.destroy();
bombs.splice(i, 1);
}
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.exploded = false;
self.touched = false;
self.lastY = 0;
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
// Physics properties
self.velocityX = 0; // Will be set during spawn
self.velocityY = 0; // Will be set during spawn
self.gravity = 0.5;
self.update = function () {
if (self.exploded) return;
self.lastY = self.y;
// Apply physics
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
// Slight rotation
bombGraphics.rotation += 0.05;
// Pulsing effect to make it look dangerous
var pulse = Math.sin(LK.ticks * 0.2) * 0.1 + 1;
bombGraphics.scaleX = pulse;
bombGraphics.scaleY = pulse;
// Add horizontal movement for moving bombs
if (self.isMoving) {
self.velocityX = Math.sin(LK.ticks * 0.05) * 8;
}
};
self.explode = function () {
if (self.exploded) return;
self.exploded = true;
// Create explosion effect
LK.effects.flashScreen(0xff0000, 500);
// Create explosion particles
for (var i = 0; i < 8; i++) {
var particle = LK.getAsset('slice_effect', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
tint: 0xff4444,
scaleX: 0.5,
scaleY: 0.5
});
game.addChild(particle);
var angle = i / 8 * Math.PI * 2;
var distance = 150;
var targetX = self.x + Math.cos(angle) * distance;
var targetY = self.y + Math.sin(angle) * distance;
tween(particle, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 600,
easing: tween.easeOut,
onFinish: function onFinish() {
particle.destroy();
}
});
}
LK.getSound('bomb_explode').play();
LK.showGameOver();
self.destroy();
};
return self;
});
var Fruit = Container.expand(function (fruitType) {
var self = Container.call(this);
self.fruitType = fruitType || 'fruit_apple';
self.sliced = false;
self.touched = false;
self.lastY = 0;
var fruitGraphics = self.attachAsset(self.fruitType, {
anchorX: 0.5,
anchorY: 0.5
});
// Physics properties
self.velocityX = 0; // Will be set during spawn
self.velocityY = 0; // Will be set during spawn
self.gravity = 0.5;
self.update = function () {
if (self.sliced) return;
self.lastY = self.y;
// Apply physics
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
// Rotate while flying
fruitGraphics.rotation += 0.1;
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
// Combo system
var currentTime = LK.ticks;
if (currentTime - lastSliceTime < 60) {
// 1 second at 60fps (much shorter window)
combo++;
} else {
combo = 1;
}
lastSliceTime = currentTime;
// Score with combo multiplier
var scoreGain = 10 * combo;
LK.setScore(LK.getScore() + scoreGain);
// Create slice effect
var sliceEffect = LK.getAsset('slice_effect', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
alpha: 0.8
});
game.addChild(sliceEffect);
// Animate slice effect
tween(sliceEffect, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
sliceEffect.destroy();
}
});
// Split fruit into two halves using separate sliced assets
var leftHalf = LK.getAsset(self.fruitType + '_left', {
anchorX: 1.0,
anchorY: 0.5,
x: self.x,
y: self.y
});
var rightHalf = LK.getAsset(self.fruitType + '_right', {
anchorX: 0.0,
anchorY: 0.5,
x: self.x,
y: self.y
});
game.addChild(leftHalf);
game.addChild(rightHalf);
// Animate left half falling quickly with rotation
tween(leftHalf, {
y: 3000,
x: leftHalf.x - 100,
rotation: Math.PI * 2
}, {
duration: 1000,
easing: tween.easeIn,
onFinish: function onFinish() {
leftHalf.destroy();
}
});
// Animate right half falling quickly with rotation
tween(rightHalf, {
y: 3000,
x: rightHalf.x + 100,
rotation: -Math.PI * 2
}, {
duration: 1000,
easing: tween.easeIn,
onFinish: function onFinish() {
rightHalf.destroy();
}
});
LK.getSound('slice').play();
self.destroy();
};
return self;
});
var GoldenFruit = Container.expand(function () {
var self = Container.call(this);
self.sliced = false;
self.touched = false;
self.lastY = 0;
self.timeLimit = 120; // 2 seconds at 60fps
self.timeLeft = self.timeLimit;
var fruitGraphics = self.attachAsset('fruit_apple', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700 // Golden color
});
// Physics properties
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8; // Falls faster
self.update = function () {
if (self.sliced) return;
self.lastY = self.y;
// Apply physics
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
// Rotate and pulse
fruitGraphics.rotation += 0.15;
var pulse = Math.sin(LK.ticks * 0.3) * 0.1 + 1;
fruitGraphics.scaleX = pulse;
fruitGraphics.scaleY = pulse;
// Decrease time left
self.timeLeft--;
if (self.timeLeft <= 0 && !self.sliced) {
// Missed golden fruit - lose combo
combo = 0;
self.destroy();
}
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
// Big bonus for golden fruit
var scoreGain = 100 + combo * 10;
LK.setScore(LK.getScore() + scoreGain);
// Don't reset combo, add to it
combo += 2;
lastSliceTime = LK.ticks;
// Create golden slice effect
for (var i = 0; i < 10; i++) {
var particle = LK.getAsset('slice_effect', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
tint: 0xFFD700,
scaleX: 0.3,
scaleY: 0.3
});
game.addChild(particle);
var angle = i / 10 * Math.PI * 2;
var distance = 200;
var targetX = self.x + Math.cos(angle) * distance;
var targetY = self.y + Math.sin(angle) * distance;
tween(particle, {
x: targetX,
y: targetY,
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
particle.destroy();
}
});
}
LK.getSound('slice').play();
self.destroy();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game variables
var fruits = [];
var bombs = [];
var goldenFruits = [];
var fruitTypes = ['fruit_apple', 'fruit_orange', 'fruit_banana'];
var spawnTimer = 0;
var spawnDelay = 90; // Spawn every 1.5 seconds at 60fps
var isSlicing = false;
var sliceStartX = 0;
var sliceStartY = 0;
var combo = 0;
var lastSliceTime = 0;
var missedFruits = 0;
var maxMissedFruits = 2; // Only 2 lives instead of 3
var difficultyLevel = 1;
var goldenSpawnTimer = 0;
var movingBombActive = false;
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Combo display
var comboTxt = new Text2('', {
size: 60,
fill: 0xFFFF00
});
comboTxt.anchor.set(0.5, 0);
comboTxt.y = 100;
LK.gui.top.addChild(comboTxt);
// Lives display
var livesTxt = new Text2('Lives: ' + maxMissedFruits, {
size: 60,
fill: 0xFF6666
});
livesTxt.anchor.set(1, 0);
livesTxt.x = -50;
LK.gui.topRight.addChild(livesTxt);
// Mouse/touch handlers for slicing
game.down = function (x, y, obj) {
isSlicing = true;
sliceStartX = x;
sliceStartY = y;
// Fruits can only be sliced by swiping, not by touching
// Check if we touched any bombs directly
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
var dx = x - bomb.x;
var dy = y - bomb.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var bombRadius = bomb.getBounds().width / 2;
if (!bomb.exploded && !bomb.touched && distance < bombRadius) {
bomb.touched = true;
bomb.explode();
bombs.splice(i, 1);
return;
}
}
};
game.move = function (x, y, obj) {
if (!isSlicing) return;
// Check if we're slicing through any fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if touch point is within fruit bounds
var dx = x - fruit.x;
var dy = y - fruit.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var fruitRadius = fruit.getBounds().width / 2;
if (!fruit.sliced && !fruit.touched && distance < fruitRadius) {
fruit.touched = true;
fruit.slice();
fruits.splice(i, 1);
}
}
// Check if we're slicing through golden fruits
for (var i = goldenFruits.length - 1; i >= 0; i--) {
var golden = goldenFruits[i];
var dx = x - golden.x;
var dy = y - golden.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var goldenRadius = golden.getBounds().width / 2;
if (!golden.sliced && !golden.touched && distance < goldenRadius) {
golden.touched = true;
golden.slice();
goldenFruits.splice(i, 1);
}
}
// Check if we're slicing through any bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
var dx = x - bomb.x;
var dy = y - bomb.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var bombRadius = bomb.getBounds().width / 2;
if (!bomb.exploded && !bomb.touched && distance < bombRadius) {
bomb.touched = true;
bomb.explode();
bombs.splice(i, 1);
return;
}
}
};
game.up = function (x, y, obj) {
isSlicing = false;
};
// Main game update
game.update = function () {
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
// Update combo display
if (combo > 1) {
comboTxt.setText('Combo x' + combo);
} else {
comboTxt.setText('');
}
// Update lives display
livesTxt.setText('Lives: ' + (maxMissedFruits - missedFruits));
// Reset combo if too much time passed
if (LK.ticks - lastSliceTime > 90) {
// 1.5 seconds (much shorter window)
combo = 0;
}
// Increase difficulty every 300 points (faster progression)
var newDifficultyLevel = Math.floor(LK.getScore() / 300) + 1;
if (newDifficultyLevel > difficultyLevel) {
difficultyLevel = newDifficultyLevel;
spawnDelay = Math.max(15, 90 - difficultyLevel * 15); // Faster spawn rate
}
// Spawn golden fruits at higher difficulty
goldenSpawnTimer++;
if (difficultyLevel >= 2 && goldenSpawnTimer > 600) {
// Every 10 seconds
goldenSpawnTimer = 0;
var golden = new GoldenFruit();
golden.x = 200 + Math.random() * 1648;
golden.y = 2732 + 50;
golden.velocityY = -45 - Math.random() * 15;
golden.velocityX = (Math.random() - 0.5) * 50;
goldenFruits.push(golden);
game.addChild(golden);
}
// Spawn new objects
spawnTimer++;
if (spawnTimer >= spawnDelay) {
spawnTimer = 0;
// Spawn multiple objects at higher difficulty
var spawnCount = Math.min(5, Math.floor(difficultyLevel / 1.5) + 1); // More objects spawn
for (var s = 0; s < spawnCount; s++) {
// Increase bomb chance with difficulty
var bombChance = Math.min(0.6, 0.25 + difficultyLevel * 0.05); // Higher bomb chance
if (Math.random() > bombChance) {
var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(fruitType);
// Random spawn position: 33% bottom, 33% left, 33% right
var spawnType = Math.random();
if (spawnType < 0.33) {
// Spawn from bottom (higher velocity)
fruit.x = 200 + Math.random() * 1648;
fruit.y = 2732 + 50;
fruit.velocityY = -40 - Math.random() * 20 - difficultyLevel * 2; // Much higher upward velocity that increases with difficulty
fruit.velocityX = (Math.random() - 0.5) * 45; // Add more horizontal velocity for angled trajectory
} else if (spawnType < 0.66) {
// Spawn from left side
fruit.x = -100;
fruit.y = 1800 + Math.random() * 600;
fruit.velocityX = 15 + Math.random() * 10 + difficultyLevel * 2; // Faster rightward velocity
fruit.velocityY = -25 - Math.random() * 15; // Higher upward velocity
} else {
// Spawn from right side
fruit.x = 2148;
fruit.y = 1800 + Math.random() * 600;
fruit.velocityX = -15 - Math.random() * 10 - difficultyLevel * 2; // Faster leftward velocity
fruit.velocityY = -25 - Math.random() * 15; // Higher upward velocity
}
fruits.push(fruit);
game.addChild(fruit);
} else {
var bomb = new Bomb();
// Add moving bombs at higher difficulty
if (difficultyLevel >= 3 && Math.random() < 0.3) {
bomb.isMoving = true;
}
// Random spawn position: 33% bottom, 33% left, 33% right
var spawnType = Math.random();
if (spawnType < 0.33) {
// Spawn from bottom (higher velocity)
bomb.x = 200 + Math.random() * 1648;
bomb.y = 2732 + 50;
bomb.velocityY = -35 - Math.random() * 20 - difficultyLevel * 1.5; // Much higher upward velocity
bomb.velocityX = (Math.random() - 0.5) * 40; // Add more horizontal velocity for angled trajectory
} else if (spawnType < 0.66) {
// Spawn from left side
bomb.x = -100;
bomb.y = 1800 + Math.random() * 600;
bomb.velocityX = 10 + Math.random() * 6; // Rightward velocity
bomb.velocityY = -18 - Math.random() * 8; // Upward velocity
} else {
// Spawn from right side
bomb.x = 2148;
bomb.y = 1800 + Math.random() * 600;
bomb.velocityX = -10 - Math.random() * 6; // Leftward velocity
bomb.velocityY = -18 - Math.random() * 8; // Upward velocity
}
bombs.push(bomb);
game.addChild(bomb);
}
}
}
// Update and clean up fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Remove fruits that fell off screen
if (fruit.y > 2732 + 200) {
if (!fruit.sliced) {
missedFruits++;
combo = 0; // Reset combo on miss
if (missedFruits >= maxMissedFruits) {
LK.showGameOver();
}
}
fruit.destroy();
fruits.splice(i, 1);
}
}
// Update and clean up golden fruits
for (var i = goldenFruits.length - 1; i >= 0; i--) {
var golden = goldenFruits[i];
// Remove golden fruits that fell off screen or timed out
if (golden.y > 2732 + 200 || golden.timeLeft <= 0) {
golden.destroy();
goldenFruits.splice(i, 1);
}
}
// Update and clean up bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
// Remove bombs that fell off screen
if (bomb.y > 2732 + 200) {
bomb.destroy();
bombs.splice(i, 1);
}
}
};
animasyon tarzı bir elma çiz. In-Game asset. 2d. High contrast. No shadows
banana. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
karpuz animasyon tarzı olsun. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bomba. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
kırmızı alanı daha fazla gözükerek yan çevir
ortadan ikiye böl
ortadan ikiye böl karpuzın içindeki kırmızı alan gözüksün