/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.isBomb = true;
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8;
var bombGraphic = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
// Make bomb flash red occasionally
self.flashTimer = 0;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
self.flashTimer++;
if (self.flashTimer % 30 < 15) {
bombGraphic.tint = 0xff0000;
} else {
bombGraphic.tint = 0xffffff;
}
};
self.explode = function () {
LK.getSound('bomb').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
};
return self;
});
var Fruit = Container.expand(function (type) {
var self = Container.call(this);
self.fruitType = type || 'apple';
self.isSliced = false;
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8;
self.rotationSpeed = 0;
// Set fruit properties based on type
if (self.fruitType === 'apple') {
self.points = 1;
self.graphic = self.attachAsset('apple', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.fruitType === 'orange') {
self.points = 2;
self.graphic = self.attachAsset('orange', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.fruitType === 'watermelon') {
self.points = 5;
self.graphic = self.attachAsset('watermelon', {
anchorX: 0.5,
anchorY: 0.5
});
}
self.rotationSpeed = (Math.random() - 0.5) * 0.2;
self.update = function () {
if (!self.isSliced) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
self.graphic.rotation += self.rotationSpeed;
}
};
self.slice = function () {
if (self.isSliced) return;
self.isSliced = true;
LK.getSound('slice').play();
// Create halves
var halfType = self.fruitType + 'Half';
var leftHalf = new FruitHalf(halfType, -1);
var rightHalf = new FruitHalf(halfType, 1);
leftHalf.x = self.x - 20;
leftHalf.y = self.y;
rightHalf.x = self.x + 20;
rightHalf.y = self.y;
leftHalf.velocityX = self.velocityX - 3;
leftHalf.velocityY = self.velocityY - 2;
rightHalf.velocityX = self.velocityX + 3;
rightHalf.velocityY = self.velocityY - 2;
game.addChild(leftHalf);
game.addChild(rightHalf);
fruitHalves.push(leftHalf);
fruitHalves.push(rightHalf);
// Create particles
createParticles(self.x, self.y);
// Add score
LK.setScore(LK.getScore() + self.points);
scoreTxt.setText(LK.getScore());
// Hide original fruit
self.visible = false;
};
return self;
});
var FruitHalf = Container.expand(function (halfType, direction) {
var self = Container.call(this);
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8;
self.rotationSpeed = direction * 0.3;
var halfGraphic = self.attachAsset(halfType, {
anchorX: 0.5,
anchorY: 0.5
});
halfGraphic.scaleX = 0.8;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
halfGraphic.rotation += self.rotationSpeed;
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
self.velocityX = (Math.random() - 0.5) * 8;
self.velocityY = (Math.random() - 0.5) * 8;
self.life = 30;
var particleGraphic = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
particleGraphic.tint = Math.random() * 0xffffff;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.life--;
particleGraphic.alpha = self.life / 30;
if (self.life <= 0) {
self.visible = false;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x8B4513
});
/****
* Game Code
****/
// Create dojo background
var woodWall = game.addChild(LK.getAsset('woodWall', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
var woodFloor = game.addChild(LK.getAsset('woodFloor', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 2732
}));
var bambooMat = game.addChild(LK.getAsset('bambooMat', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: 2732
}));
// Add some wooden planks texture effect
var woodPlank1 = game.addChild(LK.getAsset('woodFloor', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 600,
scaleY: 0.3,
alpha: 0.6
}));
var woodPlank2 = game.addChild(LK.getAsset('woodFloor', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 1200,
scaleY: 0.3,
alpha: 0.4
}));
var fruits = [];
var bombs = [];
var fruitHalves = [];
var particles = [];
var spawnTimer = 0;
var gameSpeed = 1;
var lives = 3;
var missedFruits = 0;
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create lives display
var livesTxt = new Text2('Lives: 3', {
size: 50,
fill: 0xFFFFFF
});
livesTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(livesTxt);
// Slice trail variables
var isSlicing = false;
var sliceTrail = [];
function createParticles(x, y) {
for (var i = 0; i < 8; i++) {
var particle = new Particle();
particle.x = x;
particle.y = y;
game.addChild(particle);
particles.push(particle);
}
}
function spawnFruit() {
var shouldSpawnBomb = Math.random() < 0.1; // 10% chance for bomb
if (shouldSpawnBomb) {
var bomb = new Bomb();
bomb.x = Math.random() * 1800 + 124; // Random x position
bomb.y = 2732; // Start at bottom
bomb.velocityX = (Math.random() - 0.5) * 8;
bomb.velocityY = -(Math.random() * 10 + 25) * gameSpeed;
game.addChild(bomb);
bombs.push(bomb);
} else {
var fruitTypes = ['apple', 'orange', 'watermelon'];
var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(randomType);
fruit.x = Math.random() * 1800 + 124; // Random x position
fruit.y = 2732; // Start at bottom
fruit.velocityX = (Math.random() - 0.5) * 8;
fruit.velocityY = -(Math.random() * 10 + 25) * gameSpeed;
game.addChild(fruit);
fruits.push(fruit);
}
}
function checkSliceCollisions(x, y) {
// Check fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (!fruit.isSliced && fruit.visible) {
var dx = fruit.x - x;
var dy = fruit.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < fruit.graphic.width / 2) {
fruit.slice();
}
}
}
// Check bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (bomb.visible) {
var dx = bomb.x - x;
var dy = bomb.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
bomb.explode();
return;
}
}
}
}
game.down = function (x, y, obj) {
isSlicing = true;
sliceTrail = [];
checkSliceCollisions(x, y);
};
game.move = function (x, y, obj) {
if (isSlicing) {
sliceTrail.push({
x: x,
y: y
});
if (sliceTrail.length > 10) {
sliceTrail.shift();
}
checkSliceCollisions(x, y);
}
};
game.up = function (x, y, obj) {
isSlicing = false;
sliceTrail = [];
};
game.update = function () {
spawnTimer++;
// Increase game speed over time
if (LK.ticks % 600 === 0) {
// Every 10 seconds
gameSpeed += 0.1;
}
// Spawn fruits based on game speed
var spawnRate = Math.max(60 - Math.floor(gameSpeed * 10), 20);
if (spawnTimer >= spawnRate) {
spawnFruit();
spawnTimer = 0;
}
// Update and clean up fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if fruit fell off screen
if (fruit.y > 2800 && !fruit.isSliced) {
missedFruits++;
lives--;
livesTxt.setText('Lives: ' + lives);
if (lives <= 0) {
LK.showGameOver();
return;
}
}
// Remove fruits that are off screen
if (fruit.y > 2800 || fruit.isSliced && !fruit.visible) {
fruit.destroy();
fruits.splice(i, 1);
}
}
// Update and clean up bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (bomb.y > 2800) {
bomb.destroy();
bombs.splice(i, 1);
}
}
// Update and clean up fruit halves
for (var i = fruitHalves.length - 1; i >= 0; i--) {
var half = fruitHalves[i];
if (half.y > 2800) {
half.destroy();
fruitHalves.splice(i, 1);
}
}
// Update and clean up particles
for (var i = particles.length - 1; i >= 0; i--) {
var particle = particles[i];
if (!particle.visible || particle.life <= 0) {
particle.destroy();
particles.splice(i, 1);
}
}
};
// Play background music
LK.playMusic('bgmusic'); /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Bomb = Container.expand(function () {
var self = Container.call(this);
self.isBomb = true;
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8;
var bombGraphic = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
// Make bomb flash red occasionally
self.flashTimer = 0;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
self.flashTimer++;
if (self.flashTimer % 30 < 15) {
bombGraphic.tint = 0xff0000;
} else {
bombGraphic.tint = 0xffffff;
}
};
self.explode = function () {
LK.getSound('bomb').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
};
return self;
});
var Fruit = Container.expand(function (type) {
var self = Container.call(this);
self.fruitType = type || 'apple';
self.isSliced = false;
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8;
self.rotationSpeed = 0;
// Set fruit properties based on type
if (self.fruitType === 'apple') {
self.points = 1;
self.graphic = self.attachAsset('apple', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.fruitType === 'orange') {
self.points = 2;
self.graphic = self.attachAsset('orange', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.fruitType === 'watermelon') {
self.points = 5;
self.graphic = self.attachAsset('watermelon', {
anchorX: 0.5,
anchorY: 0.5
});
}
self.rotationSpeed = (Math.random() - 0.5) * 0.2;
self.update = function () {
if (!self.isSliced) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
self.graphic.rotation += self.rotationSpeed;
}
};
self.slice = function () {
if (self.isSliced) return;
self.isSliced = true;
LK.getSound('slice').play();
// Create halves
var halfType = self.fruitType + 'Half';
var leftHalf = new FruitHalf(halfType, -1);
var rightHalf = new FruitHalf(halfType, 1);
leftHalf.x = self.x - 20;
leftHalf.y = self.y;
rightHalf.x = self.x + 20;
rightHalf.y = self.y;
leftHalf.velocityX = self.velocityX - 3;
leftHalf.velocityY = self.velocityY - 2;
rightHalf.velocityX = self.velocityX + 3;
rightHalf.velocityY = self.velocityY - 2;
game.addChild(leftHalf);
game.addChild(rightHalf);
fruitHalves.push(leftHalf);
fruitHalves.push(rightHalf);
// Create particles
createParticles(self.x, self.y);
// Add score
LK.setScore(LK.getScore() + self.points);
scoreTxt.setText(LK.getScore());
// Hide original fruit
self.visible = false;
};
return self;
});
var FruitHalf = Container.expand(function (halfType, direction) {
var self = Container.call(this);
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.8;
self.rotationSpeed = direction * 0.3;
var halfGraphic = self.attachAsset(halfType, {
anchorX: 0.5,
anchorY: 0.5
});
halfGraphic.scaleX = 0.8;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
halfGraphic.rotation += self.rotationSpeed;
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
self.velocityX = (Math.random() - 0.5) * 8;
self.velocityY = (Math.random() - 0.5) * 8;
self.life = 30;
var particleGraphic = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
particleGraphic.tint = Math.random() * 0xffffff;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.life--;
particleGraphic.alpha = self.life / 30;
if (self.life <= 0) {
self.visible = false;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x8B4513
});
/****
* Game Code
****/
// Create dojo background
var woodWall = game.addChild(LK.getAsset('woodWall', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
var woodFloor = game.addChild(LK.getAsset('woodFloor', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 2732
}));
var bambooMat = game.addChild(LK.getAsset('bambooMat', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: 2732
}));
// Add some wooden planks texture effect
var woodPlank1 = game.addChild(LK.getAsset('woodFloor', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 600,
scaleY: 0.3,
alpha: 0.6
}));
var woodPlank2 = game.addChild(LK.getAsset('woodFloor', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 1200,
scaleY: 0.3,
alpha: 0.4
}));
var fruits = [];
var bombs = [];
var fruitHalves = [];
var particles = [];
var spawnTimer = 0;
var gameSpeed = 1;
var lives = 3;
var missedFruits = 0;
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create lives display
var livesTxt = new Text2('Lives: 3', {
size: 50,
fill: 0xFFFFFF
});
livesTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(livesTxt);
// Slice trail variables
var isSlicing = false;
var sliceTrail = [];
function createParticles(x, y) {
for (var i = 0; i < 8; i++) {
var particle = new Particle();
particle.x = x;
particle.y = y;
game.addChild(particle);
particles.push(particle);
}
}
function spawnFruit() {
var shouldSpawnBomb = Math.random() < 0.1; // 10% chance for bomb
if (shouldSpawnBomb) {
var bomb = new Bomb();
bomb.x = Math.random() * 1800 + 124; // Random x position
bomb.y = 2732; // Start at bottom
bomb.velocityX = (Math.random() - 0.5) * 8;
bomb.velocityY = -(Math.random() * 10 + 25) * gameSpeed;
game.addChild(bomb);
bombs.push(bomb);
} else {
var fruitTypes = ['apple', 'orange', 'watermelon'];
var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
var fruit = new Fruit(randomType);
fruit.x = Math.random() * 1800 + 124; // Random x position
fruit.y = 2732; // Start at bottom
fruit.velocityX = (Math.random() - 0.5) * 8;
fruit.velocityY = -(Math.random() * 10 + 25) * gameSpeed;
game.addChild(fruit);
fruits.push(fruit);
}
}
function checkSliceCollisions(x, y) {
// Check fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (!fruit.isSliced && fruit.visible) {
var dx = fruit.x - x;
var dy = fruit.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < fruit.graphic.width / 2) {
fruit.slice();
}
}
}
// Check bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (bomb.visible) {
var dx = bomb.x - x;
var dy = bomb.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
bomb.explode();
return;
}
}
}
}
game.down = function (x, y, obj) {
isSlicing = true;
sliceTrail = [];
checkSliceCollisions(x, y);
};
game.move = function (x, y, obj) {
if (isSlicing) {
sliceTrail.push({
x: x,
y: y
});
if (sliceTrail.length > 10) {
sliceTrail.shift();
}
checkSliceCollisions(x, y);
}
};
game.up = function (x, y, obj) {
isSlicing = false;
sliceTrail = [];
};
game.update = function () {
spawnTimer++;
// Increase game speed over time
if (LK.ticks % 600 === 0) {
// Every 10 seconds
gameSpeed += 0.1;
}
// Spawn fruits based on game speed
var spawnRate = Math.max(60 - Math.floor(gameSpeed * 10), 20);
if (spawnTimer >= spawnRate) {
spawnFruit();
spawnTimer = 0;
}
// Update and clean up fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if fruit fell off screen
if (fruit.y > 2800 && !fruit.isSliced) {
missedFruits++;
lives--;
livesTxt.setText('Lives: ' + lives);
if (lives <= 0) {
LK.showGameOver();
return;
}
}
// Remove fruits that are off screen
if (fruit.y > 2800 || fruit.isSliced && !fruit.visible) {
fruit.destroy();
fruits.splice(i, 1);
}
}
// Update and clean up bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (bomb.y > 2800) {
bomb.destroy();
bombs.splice(i, 1);
}
}
// Update and clean up fruit halves
for (var i = fruitHalves.length - 1; i >= 0; i--) {
var half = fruitHalves[i];
if (half.y > 2800) {
half.destroy();
fruitHalves.splice(i, 1);
}
}
// Update and clean up particles
for (var i = particles.length - 1; i >= 0; i--) {
var particle = particles[i];
if (!particle.visible || particle.life <= 0) {
particle.destroy();
particles.splice(i, 1);
}
}
};
// Play background music
LK.playMusic('bgmusic');
Fruit ninja eski elmalar. In-Game asset. 2d. High contrast. No shadows
Fruit binadaki karpuz. In-Game asset. 2d. High contrast. No shadows
Kavun. In-Game asset. 2d. High contrast. No shadows
Portakal. In-Game asset. 2d. High contrast. No shadows
Muz,banana. In-Game asset. 2d. High contrast. No shadows
Bomba. In-Game asset. 2d. High contrast. No shadows
Çilek. In-Game asset. 2d. High contrast. No shadows
Ahşap duvr. In-Game asset. 2d. High contrast. No shadows
Ahşap zemin. In-Game asset. 2d. High contrast. No shadows
Bambu mat. In-Game asset. 2d. High contrast. No shadows