/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.sliced = false;
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 4;
self.speedY = Math.random() * -25 - 20;
self.gravity = 0.3;
self.update = function () {
if (!self.sliced) {
self.x += self.speedX;
self.y += self.speedY;
self.speedY += self.gravity;
}
};
self.explode = function () {
if (self.sliced) return;
self.sliced = true;
LK.getSound('bomb').play();
// Flash screen and show game over
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
};
return self;
});
var CuttingLine = Container.expand(function () {
var self = Container.call(this);
self.points = [];
self.lineSegments = [];
self.active = true;
self.lifetime = 0;
self.addPoint = function (x, y) {
self.points.push({
x: x,
y: y
});
if (self.points.length > 1) {
var prevPoint = self.points[self.points.length - 2];
var currentPoint = self.points[self.points.length - 1];
var distance = Math.sqrt(Math.pow(currentPoint.x - prevPoint.x, 2) + Math.pow(currentPoint.y - prevPoint.y, 2));
var steps = Math.ceil(distance / 15);
for (var i = 0; i < steps; i++) {
var t = i / steps;
var x = prevPoint.x + (currentPoint.x - prevPoint.x) * t;
var y = prevPoint.y + (currentPoint.y - prevPoint.y) * t;
var segment = self.addChild(LK.getAsset('cuttingLine', {
anchorX: 0.5,
anchorY: 0.5
}));
segment.x = x;
segment.y = y;
self.lineSegments.push(segment);
}
}
};
self.update = function () {
self.lifetime++;
if (self.lifetime > 60) {
self.active = false;
for (var i = 0; i < self.lineSegments.length; i++) {
tween(self.lineSegments[i], {
alpha: 0
}, {
duration: 300
});
}
LK.setTimeout(function () {
self.destroy();
}, 300);
}
};
self.intersectsWithFruit = function (fruit) {
if (!self.active || fruit.sliced) return false;
var fruitRadius = fruit.width / 2;
for (var i = 0; i < self.lineSegments.length; i++) {
var segment = self.lineSegments[i];
var distance = Math.sqrt(Math.pow(segment.x - fruit.x, 2) + Math.pow(segment.y - fruit.y, 2));
if (distance < fruitRadius + 10) {
return true;
}
}
return false;
};
return self;
});
var Fruit = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'apple';
self.points = 10;
self.sliced = false;
var colors = {
apple: 0xff4444,
orange: 0xff8800,
banana: 0xffff00,
watermelon: 0x44ff44
};
var sizes = {
apple: {
width: 120,
height: 120,
points: 10
},
orange: {
width: 100,
height: 100,
points: 15
},
banana: {
width: 140,
height: 80,
points: 20
},
watermelon: {
width: 160,
height: 160,
points: 25
}
};
self.points = sizes[self.type].points;
var fruitGraphics = self.attachAsset(self.type, {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 4;
self.speedY = Math.random() * -25 - 20;
self.gravity = 0.3;
self.rotation = (Math.random() - 0.5) * 0.2;
self.update = function () {
if (!self.sliced) {
self.x += self.speedX;
self.y += self.speedY;
self.speedY += self.gravity;
fruitGraphics.rotation += self.rotation;
}
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
LK.getSound('slice').play();
// Create two halves
var half1 = LK.getAsset('fruitHalf', {
anchorX: 0.5,
anchorY: 0.5,
tint: colors[self.type]
});
half1.x = self.x - 20;
half1.y = self.y;
var half2 = LK.getAsset('fruitHalf', {
anchorX: 0.5,
anchorY: 0.5,
tint: colors[self.type]
});
half2.x = self.x + 20;
half2.y = self.y;
game.addChild(half1);
game.addChild(half2);
// Animate halves falling
tween(half1, {
y: half1.y + 300,
alpha: 0
}, {
duration: 1000
});
tween(half2, {
y: half2.y + 300,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
half1.destroy();
half2.destroy();
}
});
// Flash fruit before removal
tween(fruitGraphics, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xffffff
});
/****
* Game Code
****/
var fruits = [];
var bombs = [];
var cuttingLines = [];
var currentCuttingLine = null;
var isSlicing = false;
var comboCount = 0;
var comboTimer = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: 0x000000
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var comboTxt = new Text2('', {
size: 80,
fill: 0xFFFF00
});
comboTxt.anchor.set(0.5, 0);
comboTxt.y = 150;
LK.gui.top.addChild(comboTxt);
// Spawn fruits and bombs
var spawnTimer = LK.setInterval(function () {
var spawnChance = Math.random();
if (spawnChance < 0.15) {
// Spawn bomb
var bomb = new Bomb();
bomb.x = Math.random() * 1800 + 124;
bomb.y = 2732;
bombs.push(bomb);
game.addChild(bomb);
} else {
// Spawn fruit
var fruitTypes = ['apple', 'orange', 'banana', 'watermelon'];
var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(fruitType);
fruit.x = Math.random() * 1800 + 124;
fruit.y = 2732;
fruits.push(fruit);
game.addChild(fruit);
}
}, 800);
game.down = function (x, y, obj) {
isSlicing = true;
currentCuttingLine = new CuttingLine();
currentCuttingLine.addPoint(x, y);
cuttingLines.push(currentCuttingLine);
game.addChild(currentCuttingLine);
};
game.move = function (x, y, obj) {
if (isSlicing && currentCuttingLine) {
currentCuttingLine.addPoint(x, y);
}
};
game.up = function (x, y, obj) {
isSlicing = false;
currentCuttingLine = null;
};
game.update = function () {
// Update combo timer
if (comboTimer > 0) {
comboTimer--;
if (comboTimer <= 0) {
comboCount = 0;
comboTxt.setText('');
}
}
// Check fruit collisions with cutting lines
var slicedThisFrame = 0;
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Remove fruits that fall off screen
if (fruit.y > 2732 && !fruit.sliced) {
fruit.destroy();
fruits.splice(i, 1);
continue;
}
// Check collision with cutting lines
for (var j = 0; j < cuttingLines.length; j++) {
var line = cuttingLines[j];
if (line.intersectsWithFruit(fruit)) {
var points = fruit.points;
// Apply combo multiplier
if (comboCount > 0) {
points *= comboCount + 1;
}
LK.setScore(LK.getScore() + points);
scoreTxt.setText(LK.getScore());
fruit.slice();
fruits.splice(i, 1);
slicedThisFrame++;
break;
}
}
}
// Update combo
if (slicedThisFrame > 1) {
comboCount += slicedThisFrame - 1;
comboTimer = 120; // 2 seconds at 60fps
comboTxt.setText('COMBO x' + (comboCount + 1));
} else if (slicedThisFrame == 1) {
comboTimer = 120;
}
// Check bomb collisions with cutting lines
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
// Remove bombs that fall off screen
if (bomb.y > 2732 && !bomb.sliced) {
bomb.destroy();
bombs.splice(i, 1);
continue;
}
// Check collision with cutting lines
for (var j = 0; j < cuttingLines.length; j++) {
var line = cuttingLines[j];
if (line.intersectsWithFruit(bomb)) {
bomb.explode();
bombs.splice(i, 1);
break;
}
}
}
// Clean up inactive cutting lines
for (var i = cuttingLines.length - 1; i >= 0; i--) {
var line = cuttingLines[i];
if (!line.active && line.parent == null) {
cuttingLines.splice(i, 1);
}
}
// Increase difficulty based on score
var currentScore = LK.getScore();
if (currentScore >= 500 && LK.ticks % 600 == 0) {
// Spawn extra fruit at higher scores
var fruitTypes = ['apple', 'orange', 'banana', 'watermelon'];
var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(fruitType);
fruit.x = Math.random() * 1800 + 124;
fruit.y = 2732;
fruits.push(fruit);
game.addChild(fruit);
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.sliced = false;
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 4;
self.speedY = Math.random() * -25 - 20;
self.gravity = 0.3;
self.update = function () {
if (!self.sliced) {
self.x += self.speedX;
self.y += self.speedY;
self.speedY += self.gravity;
}
};
self.explode = function () {
if (self.sliced) return;
self.sliced = true;
LK.getSound('bomb').play();
// Flash screen and show game over
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
};
return self;
});
var CuttingLine = Container.expand(function () {
var self = Container.call(this);
self.points = [];
self.lineSegments = [];
self.active = true;
self.lifetime = 0;
self.addPoint = function (x, y) {
self.points.push({
x: x,
y: y
});
if (self.points.length > 1) {
var prevPoint = self.points[self.points.length - 2];
var currentPoint = self.points[self.points.length - 1];
var distance = Math.sqrt(Math.pow(currentPoint.x - prevPoint.x, 2) + Math.pow(currentPoint.y - prevPoint.y, 2));
var steps = Math.ceil(distance / 15);
for (var i = 0; i < steps; i++) {
var t = i / steps;
var x = prevPoint.x + (currentPoint.x - prevPoint.x) * t;
var y = prevPoint.y + (currentPoint.y - prevPoint.y) * t;
var segment = self.addChild(LK.getAsset('cuttingLine', {
anchorX: 0.5,
anchorY: 0.5
}));
segment.x = x;
segment.y = y;
self.lineSegments.push(segment);
}
}
};
self.update = function () {
self.lifetime++;
if (self.lifetime > 60) {
self.active = false;
for (var i = 0; i < self.lineSegments.length; i++) {
tween(self.lineSegments[i], {
alpha: 0
}, {
duration: 300
});
}
LK.setTimeout(function () {
self.destroy();
}, 300);
}
};
self.intersectsWithFruit = function (fruit) {
if (!self.active || fruit.sliced) return false;
var fruitRadius = fruit.width / 2;
for (var i = 0; i < self.lineSegments.length; i++) {
var segment = self.lineSegments[i];
var distance = Math.sqrt(Math.pow(segment.x - fruit.x, 2) + Math.pow(segment.y - fruit.y, 2));
if (distance < fruitRadius + 10) {
return true;
}
}
return false;
};
return self;
});
var Fruit = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'apple';
self.points = 10;
self.sliced = false;
var colors = {
apple: 0xff4444,
orange: 0xff8800,
banana: 0xffff00,
watermelon: 0x44ff44
};
var sizes = {
apple: {
width: 120,
height: 120,
points: 10
},
orange: {
width: 100,
height: 100,
points: 15
},
banana: {
width: 140,
height: 80,
points: 20
},
watermelon: {
width: 160,
height: 160,
points: 25
}
};
self.points = sizes[self.type].points;
var fruitGraphics = self.attachAsset(self.type, {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 4;
self.speedY = Math.random() * -25 - 20;
self.gravity = 0.3;
self.rotation = (Math.random() - 0.5) * 0.2;
self.update = function () {
if (!self.sliced) {
self.x += self.speedX;
self.y += self.speedY;
self.speedY += self.gravity;
fruitGraphics.rotation += self.rotation;
}
};
self.slice = function () {
if (self.sliced) return;
self.sliced = true;
LK.getSound('slice').play();
// Create two halves
var half1 = LK.getAsset('fruitHalf', {
anchorX: 0.5,
anchorY: 0.5,
tint: colors[self.type]
});
half1.x = self.x - 20;
half1.y = self.y;
var half2 = LK.getAsset('fruitHalf', {
anchorX: 0.5,
anchorY: 0.5,
tint: colors[self.type]
});
half2.x = self.x + 20;
half2.y = self.y;
game.addChild(half1);
game.addChild(half2);
// Animate halves falling
tween(half1, {
y: half1.y + 300,
alpha: 0
}, {
duration: 1000
});
tween(half2, {
y: half2.y + 300,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
half1.destroy();
half2.destroy();
}
});
// Flash fruit before removal
tween(fruitGraphics, {
alpha: 0
}, {
duration: 200,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xffffff
});
/****
* Game Code
****/
var fruits = [];
var bombs = [];
var cuttingLines = [];
var currentCuttingLine = null;
var isSlicing = false;
var comboCount = 0;
var comboTimer = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: 0x000000
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var comboTxt = new Text2('', {
size: 80,
fill: 0xFFFF00
});
comboTxt.anchor.set(0.5, 0);
comboTxt.y = 150;
LK.gui.top.addChild(comboTxt);
// Spawn fruits and bombs
var spawnTimer = LK.setInterval(function () {
var spawnChance = Math.random();
if (spawnChance < 0.15) {
// Spawn bomb
var bomb = new Bomb();
bomb.x = Math.random() * 1800 + 124;
bomb.y = 2732;
bombs.push(bomb);
game.addChild(bomb);
} else {
// Spawn fruit
var fruitTypes = ['apple', 'orange', 'banana', 'watermelon'];
var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(fruitType);
fruit.x = Math.random() * 1800 + 124;
fruit.y = 2732;
fruits.push(fruit);
game.addChild(fruit);
}
}, 800);
game.down = function (x, y, obj) {
isSlicing = true;
currentCuttingLine = new CuttingLine();
currentCuttingLine.addPoint(x, y);
cuttingLines.push(currentCuttingLine);
game.addChild(currentCuttingLine);
};
game.move = function (x, y, obj) {
if (isSlicing && currentCuttingLine) {
currentCuttingLine.addPoint(x, y);
}
};
game.up = function (x, y, obj) {
isSlicing = false;
currentCuttingLine = null;
};
game.update = function () {
// Update combo timer
if (comboTimer > 0) {
comboTimer--;
if (comboTimer <= 0) {
comboCount = 0;
comboTxt.setText('');
}
}
// Check fruit collisions with cutting lines
var slicedThisFrame = 0;
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Remove fruits that fall off screen
if (fruit.y > 2732 && !fruit.sliced) {
fruit.destroy();
fruits.splice(i, 1);
continue;
}
// Check collision with cutting lines
for (var j = 0; j < cuttingLines.length; j++) {
var line = cuttingLines[j];
if (line.intersectsWithFruit(fruit)) {
var points = fruit.points;
// Apply combo multiplier
if (comboCount > 0) {
points *= comboCount + 1;
}
LK.setScore(LK.getScore() + points);
scoreTxt.setText(LK.getScore());
fruit.slice();
fruits.splice(i, 1);
slicedThisFrame++;
break;
}
}
}
// Update combo
if (slicedThisFrame > 1) {
comboCount += slicedThisFrame - 1;
comboTimer = 120; // 2 seconds at 60fps
comboTxt.setText('COMBO x' + (comboCount + 1));
} else if (slicedThisFrame == 1) {
comboTimer = 120;
}
// Check bomb collisions with cutting lines
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
// Remove bombs that fall off screen
if (bomb.y > 2732 && !bomb.sliced) {
bomb.destroy();
bombs.splice(i, 1);
continue;
}
// Check collision with cutting lines
for (var j = 0; j < cuttingLines.length; j++) {
var line = cuttingLines[j];
if (line.intersectsWithFruit(bomb)) {
bomb.explode();
bombs.splice(i, 1);
break;
}
}
}
// Clean up inactive cutting lines
for (var i = cuttingLines.length - 1; i >= 0; i--) {
var line = cuttingLines[i];
if (!line.active && line.parent == null) {
cuttingLines.splice(i, 1);
}
}
// Increase difficulty based on score
var currentScore = LK.getScore();
if (currentScore >= 500 && LK.ticks % 600 == 0) {
// Spawn extra fruit at higher scores
var fruitTypes = ['apple', 'orange', 'banana', 'watermelon'];
var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(fruitType);
fruit.x = Math.random() * 1800 + 124;
fruit.y = 2732;
fruits.push(fruit);
game.addChild(fruit);
}
};
no background. just bomb picture. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
just banana picture.. In-Game asset. 2d. High contrast. No shadows
just apple picture.. In-Game asset. 2d. High contrast. No shadows
just kitchen knife pictures.. In-Game asset. 2d. High contrast. No shadows
just orange picture.. In-Game asset. 2d. High contrast. No shadows
just watermelon picture.. In-Game asset. 2d. High contrast. No shadows
Picture of a straight cutting line in red.. In-Game asset. 2d. High contrast. No shadows