User prompt
Ana menü için resim kaynagı ekle
User prompt
Ana menü oluşturmak istiyorum
User prompt
Bomba daha yukarı fırlayabilir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bomba fizigini geri al
User prompt
Bombabneyveler gibi yukarı zıplayanilir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Geri al
User prompt
Ekranda en az 2 en fazla 6 meyve olabilir
User prompt
Meyveler muzlar çilekler biraz daha yukarı fırlayabilir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yeni bir meyve daha oluştur çilek ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Muz meyve gibi 3 4 tane birden yumurtlayabilir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Muz yumurtlama meyve yumurtlama ile aynı ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Muz yumurtlamayı arttır ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ueni bir meyve varlıgı ekle muz ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Parçacık şeklini geri al ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Parçacıkları su damlası şeklinde yap ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Meyveleri cok az küçült ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Meyveleri biraz büyült ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yayılan parçacık taneleri biraz geç kaybolsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Parcacık animasyon sesi ekle
User prompt
Meyve kesilme sesi ekle
User prompt
Dokunma sesi ekle
User prompt
Ama oyın ekranında ekledigim anaekran renginden farklı bir renk gözüküyor çok az olsada
User prompt
Ana arkaplan için resim varlıgo
User prompt
Ana arkaplan hariç büyğn arkaplanları kaldır
User prompt
Dokunma animasyonu daha belirgin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Banana = Container.expand(function () {
var self = Container.call(this);
var bananaGraphics = self.attachAsset('banana', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.3;
self.sliced = false;
self.update = function () {
if (!self.sliced) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
// Boundary collision - bounce off left and right edges
if (self.x <= 120 && self.velocityX < 0) {
self.velocityX = -self.velocityX * 0.8; // Reverse and dampen velocity
self.x = 120; // Keep within bounds
}
if (self.x >= 1928 && self.velocityX > 0) {
self.velocityX = -self.velocityX * 0.8; // Reverse and dampen velocity
self.x = 1928; // Keep within bounds
}
// Rotate banana as it moves
bananaGraphics.rotation += 0.03;
}
};
return self;
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.3;
self.sliced = false;
self.update = function () {
if (!self.sliced) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
// Flash bomb red occasionally
if (LK.ticks % 30 < 15) {
bombGraphics.tint = 0xff0000;
} else {
bombGraphics.tint = 0x333333;
}
}
};
return self;
});
var Fruit = Container.expand(function () {
var self = Container.call(this);
var fruitGraphics = self.attachAsset('fruit', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.3;
self.sliced = false;
self.update = function () {
if (!self.sliced) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
// Boundary collision - bounce off left and right edges
if (self.x <= 120 && self.velocityX < 0) {
self.velocityX = -self.velocityX * 0.8; // Reverse and dampen velocity
self.x = 120; // Keep within bounds
}
if (self.x >= 1928 && self.velocityX > 0) {
self.velocityX = -self.velocityX * 0.8; // Reverse and dampen velocity
self.x = 1928; // Keep within bounds
}
// Rotate fruit as it moves
fruitGraphics.rotation += 0.05;
}
};
return self;
});
var KnifeTrail = Container.expand(function () {
var self = Container.call(this);
var trailGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.life = 60;
self.maxLife = 60;
// Knife trail appearance - much larger and more prominent
self.scaleX = 8.0;
self.scaleY = 1.5;
trailGraphics.tint = 0xffffff; // Bright white for maximum visibility
// Animate knife trail - starts bright and fades slowly with glow
tween(self, {
scaleX: 0.5,
scaleY: 0.1,
alpha: 0
}, {
duration: 600,
easing: tween.easeOut
});
// Add secondary glow effect
tween(trailGraphics, {
tint: 0x00ffff
}, {
duration: 300,
easing: tween.easeInOut
});
self.update = function () {
self.life--;
if (self.life <= 0) {
self.destroy();
}
};
return self;
});
var MainMenu = Container.expand(function () {
var self = Container.call(this);
// Create menu background
var menuBg = self.attachAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
menuBg.tint = 0x2c3e50;
// Game title
var titleText = new Text2('FRUIT NINJA', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 800;
self.addChild(titleText);
// Play button
var playButton = self.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400,
width: 400,
height: 120
});
playButton.tint = 0x27ae60;
var playText = new Text2('OYNA', {
size: 60,
fill: 0xFFFFFF
});
playText.anchor.set(0.5, 0.5);
playText.x = 1024;
playText.y = 1400;
self.addChild(playText);
// High score display
var highScoreText = new Text2('En Yüksek Skor: 0', {
size: 50,
fill: 0xFFFFFF
});
highScoreText.anchor.set(0.5, 0.5);
highScoreText.x = 1024;
highScoreText.y = 1600;
self.addChild(highScoreText);
// Play button interaction
playButton.down = function (x, y, obj) {
LK.getSound('touch_sound').play();
startGame();
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = (Math.random() - 0.5) * 24;
self.velocityY = (Math.random() - 0.5) * 24;
self.life = 180;
self.maxLife = 180;
// Start with random scale and animate
self.scaleX = 0.4 + Math.random() * 1.5;
self.scaleY = 0.4 + Math.random() * 1.5;
// Animate scale down over time with rotation
tween(self, {
scaleX: 0.03,
scaleY: 0.03,
rotation: Math.PI * 4
}, {
duration: 4000,
easing: tween.easeOut
});
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.life--;
self.alpha = self.life / self.maxLife;
self.velocityY += 0.4;
// Add slight scale pulsing effect
var pulseFactor = 0.8 + 0.4 * Math.sin(LK.ticks * 0.1);
particleGraphics.scaleX = self.scaleX * pulseFactor;
particleGraphics.scaleY = self.scaleY * pulseFactor;
if (self.life <= 0) {
self.destroy();
}
};
return self;
});
var Strawberry = Container.expand(function () {
var self = Container.call(this);
var strawberryGraphics = self.attachAsset('strawberry', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.3;
self.sliced = false;
self.update = function () {
if (!self.sliced) {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
// Boundary collision - bounce off left and right edges
if (self.x <= 120 && self.velocityX < 0) {
self.velocityX = -self.velocityX * 0.8; // Reverse and dampen velocity
self.x = 120; // Keep within bounds
}
if (self.x >= 1928 && self.velocityX > 0) {
self.velocityX = -self.velocityX * 0.8; // Reverse and dampen velocity
self.x = 1928; // Keep within bounds
}
// Rotate strawberry as it moves
strawberryGraphics.rotation += 0.04;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game state variables
var gameState = 'menu'; // 'menu' or 'playing'
var mainMenu = null;
var gameBackground = null;
// Game arrays and variables
var fruits = [];
var bananas = [];
var strawberries = [];
var bombs = [];
var particles = [];
var knifeTrails = [];
var sliceTrail = [];
var isSlicing = false;
var lastSliceX = 0;
var lastSliceY = 0;
var comboCount = 0;
var spawnRate = 120;
var gameSpeed = 1;
// Initialize main menu
function initMainMenu() {
mainMenu = new MainMenu();
game.addChild(mainMenu);
}
// Start the actual game
function startGame() {
gameState = 'playing';
// Remove main menu
if (mainMenu) {
mainMenu.destroy();
mainMenu = null;
}
// Add game background
gameBackground = game.attachAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
// Reset game variables
LK.setScore(0);
gameSpeed = 1;
spawnRate = 120;
comboCount = 0;
}
// Initialize main menu at start
initMainMenu();
// 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);
function spawnFruit() {
// Spawn multiple fruits (2-4 fruits at once)
var fruitCount = 2 + Math.floor(Math.random() * 3); // Random between 2-4 fruits
for (var j = 0; j < fruitCount; j++) {
var fruit = new Fruit();
fruit.x = Math.random() * 1600 + 224;
fruit.y = 2732 + 100;
// Random trajectory upward with higher velocity
fruit.velocityX = (Math.random() - 0.5) * 8;
fruit.velocityY = -22 - Math.random() * 16;
// Start small and scale up with tween animation
fruit.scaleX = 0.3;
fruit.scaleY = 0.3;
tween(fruit, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.easeOut
});
fruits.push(fruit);
game.addChild(fruit);
}
}
function spawnBanana() {
// Spawn multiple bananas (2-4 bananas at once)
var bananaCount = 2 + Math.floor(Math.random() * 3); // Random between 2-4 bananas
for (var j = 0; j < bananaCount; j++) {
var banana = new Banana();
banana.x = Math.random() * 1600 + 224;
banana.y = 2732 + 100;
banana.velocityX = (Math.random() - 0.5) * 7;
banana.velocityY = -21 - Math.random() * 15;
// Start small and scale up with tween animation
banana.scaleX = 0.3;
banana.scaleY = 0.3;
tween(banana, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 350,
easing: tween.easeOut
});
bananas.push(banana);
game.addChild(banana);
}
}
function spawnStrawberry() {
// Spawn multiple strawberries (2-4 strawberries at once)
var strawberryCount = 2 + Math.floor(Math.random() * 3); // Random between 2-4 strawberries
for (var j = 0; j < strawberryCount; j++) {
var strawberry = new Strawberry();
strawberry.x = Math.random() * 1600 + 224;
strawberry.y = 2732 + 100;
strawberry.velocityX = (Math.random() - 0.5) * 6;
strawberry.velocityY = -20 - Math.random() * 14;
// Start small and scale up with tween animation
strawberry.scaleX = 0.3;
strawberry.scaleY = 0.3;
tween(strawberry, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 320,
easing: tween.easeOut
});
strawberries.push(strawberry);
game.addChild(strawberry);
}
}
function spawnBomb() {
var bomb = new Bomb();
bomb.x = Math.random() * 1600 + 224;
bomb.y = 2732 + 100;
bomb.velocityX = (Math.random() - 0.5) * 6;
bomb.velocityY = -24 - Math.random() * 16;
// Start small and scale up with tween animation
bomb.scaleX = 0.3;
bomb.scaleY = 0.3;
tween(bomb, {
scaleX: 1,
scaleY: 1
}, {
duration: 400,
easing: tween.bounceOut
});
bombs.push(bomb);
game.addChild(bomb);
}
function createParticles(x, y, color) {
for (var i = 0; i < 40; i++) {
var particle = new Particle();
particle.x = x + (Math.random() - 0.5) * 120;
particle.y = y + (Math.random() - 0.5) * 120;
var particleGraphics = particle.children[0];
// Create color variations with more vibrant colors
var colors = [color, 0xffffff, 0xffff00, 0xff6600, 0xff0066];
var selectedColor = colors[Math.floor(Math.random() * colors.length)];
particleGraphics.tint = selectedColor;
particleGraphics.alpha = 0.9 + Math.random() * 0.1;
// Add color transition animation
tween(particleGraphics, {
tint: 0x000000,
alpha: 0
}, {
duration: 3600,
easing: tween.easeInOut
});
particles.push(particle);
game.addChild(particle);
}
}
function checkSliceCollision(x1, y1, x2, y2, target) {
var dx = target.x - x1;
var dy = target.y - y1;
var lineX = x2 - x1;
var lineY = y2 - y1;
var lineLength = Math.sqrt(lineX * lineX + lineY * lineY);
if (lineLength === 0) return false;
var dot = (dx * lineX + dy * lineY) / (lineLength * lineLength);
dot = Math.max(0, Math.min(1, dot));
var closestX = x1 + dot * lineX;
var closestY = y1 + dot * lineY;
var distance = Math.sqrt((target.x - closestX) * (target.x - closestX) + (target.y - closestY) * (target.y - closestY));
return distance < 120; // Hit radius
}
game.down = function (x, y, obj) {
if (gameState !== 'playing') return;
isSlicing = true;
lastSliceX = x;
lastSliceY = y;
sliceTrail = [{
x: x,
y: y
}];
comboCount = 0;
// Play touch sound when user starts slicing
LK.getSound('touch_sound').play();
};
game.move = function (x, y, obj) {
if (gameState !== 'playing') return;
if (isSlicing) {
// Create knife trails more frequently for denser effect
var distance = Math.sqrt((x - lastSliceX) * (x - lastSliceX) + (y - lastSliceY) * (y - lastSliceY));
if (distance > 8) {
var knifeTrail = new KnifeTrail();
knifeTrail.x = x;
knifeTrail.y = y;
// Rotate knife trail to match movement direction
var angle = Math.atan2(y - lastSliceY, x - lastSliceX);
knifeTrail.rotation = angle;
knifeTrails.push(knifeTrail);
game.addChild(knifeTrail);
}
// Add to slice trail
sliceTrail.push({
x: x,
y: y
});
if (sliceTrail.length > 10) {
sliceTrail.shift();
}
// Check slice collision with fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (!fruit.sliced && checkSliceCollision(lastSliceX, lastSliceY, x, y, fruit)) {
fruit.sliced = true;
comboCount++;
var baseScore = 10;
var comboBonus = comboCount > 1 ? (comboCount - 1) * 5 : 0;
LK.setScore(LK.getScore() + baseScore + comboBonus);
// Create particles
var fruitColor = fruit.children[0].tint;
createParticles(fruit.x, fruit.y, fruitColor);
// Play fruit cutting sound
LK.getSound('fruit_cut_sound').play();
// Play particle animation sound
LK.getSound('particle_sound').play();
// Remove fruit
fruit.destroy();
fruits.splice(i, 1);
}
}
// Check slice collision with bananas
for (var i = bananas.length - 1; i >= 0; i--) {
var banana = bananas[i];
if (!banana.sliced && checkSliceCollision(lastSliceX, lastSliceY, x, y, banana)) {
banana.sliced = true;
comboCount++;
var baseScore = 15; // Bananas worth more points
var comboBonus = comboCount > 1 ? (comboCount - 1) * 5 : 0;
LK.setScore(LK.getScore() + baseScore + comboBonus);
// Create particles with yellow tint for bananas
createParticles(banana.x, banana.y, 0xffff00);
// Play fruit cutting sound
LK.getSound('fruit_cut_sound').play();
// Play particle animation sound
LK.getSound('particle_sound').play();
// Remove banana
banana.destroy();
bananas.splice(i, 1);
}
}
// Check slice collision with strawberries
for (var i = strawberries.length - 1; i >= 0; i--) {
var strawberry = strawberries[i];
if (!strawberry.sliced && checkSliceCollision(lastSliceX, lastSliceY, x, y, strawberry)) {
strawberry.sliced = true;
comboCount++;
var baseScore = 12; // Strawberries worth medium points
var comboBonus = comboCount > 1 ? (comboCount - 1) * 5 : 0;
LK.setScore(LK.getScore() + baseScore + comboBonus);
// Create particles with red tint for strawberries
createParticles(strawberry.x, strawberry.y, 0xff3366);
// Play fruit cutting sound
LK.getSound('fruit_cut_sound').play();
// Play particle animation sound
LK.getSound('particle_sound').play();
// Remove strawberry
strawberry.destroy();
strawberries.splice(i, 1);
}
}
// Check slice collision with bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (!bomb.sliced && checkSliceCollision(lastSliceX, lastSliceY, x, y, bomb)) {
bomb.sliced = true;
// Game over
LK.getSound('bomb_sound').play();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
lastSliceX = x;
lastSliceY = y;
}
};
game.up = function (x, y, obj) {
if (gameState !== 'playing') return;
isSlicing = false;
sliceTrail = [];
if (comboCount > 1) {
comboTxt.setText('COMBO x' + comboCount + '!');
tween(comboTxt, {
alpha: 0
}, {
duration: 2000,
onFinish: function onFinish() {
comboTxt.setText('');
comboTxt.alpha = 1;
}
});
}
comboCount = 0;
};
game.update = function () {
if (gameState !== 'playing') return;
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
// Increase difficulty over time
if (LK.ticks % 600 === 0) {
gameSpeed += 0.1;
spawnRate = Math.max(60, spawnRate - 5);
}
// Check if all fruits and bombs have fallen (are off-screen at bottom)
var allFallen = true;
for (var i = 0; i < fruits.length; i++) {
if (fruits[i].y < 2732 + 200) {
allFallen = false;
break;
}
}
if (allFallen) {
for (var i = 0; i < bananas.length; i++) {
if (bananas[i].y < 2732 + 200) {
allFallen = false;
break;
}
}
}
if (allFallen) {
for (var i = 0; i < strawberries.length; i++) {
if (strawberries[i].y < 2732 + 200) {
allFallen = false;
break;
}
}
}
if (allFallen) {
for (var i = 0; i < bombs.length; i++) {
if (bombs[i].y < 2732 + 200) {
allFallen = false;
break;
}
}
}
// Only spawn new fruits if all previous ones have fallen
if (allFallen && LK.ticks % Math.floor(spawnRate / gameSpeed) === 0) {
var randomValue = Math.random();
if (randomValue < 0.33) {
spawnBanana(); // 33% chance to spawn banana
} else if (randomValue < 0.66) {
spawnStrawberry(); // 33% chance to spawn strawberry
} else {
spawnFruit(); // 33% chance to spawn fruit
}
}
// Only spawn new bombs if all fruits and bombs have fallen
if (allFallen && LK.ticks % Math.floor(300 / gameSpeed) === 0 && Math.random() < 0.3) {
spawnBomb();
}
// Clean up off-screen fruits
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (fruit.y > 2732 + 200 || fruit.x < -200 || fruit.x > 2248) {
fruit.destroy();
fruits.splice(i, 1);
}
}
// Clean up off-screen bananas
for (var i = bananas.length - 1; i >= 0; i--) {
var banana = bananas[i];
if (banana.y > 2732 + 200 || banana.x < -200 || banana.x > 2248) {
banana.destroy();
bananas.splice(i, 1);
}
}
// Clean up off-screen strawberries
for (var i = strawberries.length - 1; i >= 0; i--) {
var strawberry = strawberries[i];
if (strawberry.y > 2732 + 200 || strawberry.x < -200 || strawberry.x > 2248) {
strawberry.destroy();
strawberries.splice(i, 1);
}
}
// Clean up off-screen bombs
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (bomb.y > 2732 + 200 || bomb.x < -200 || bomb.x > 2248) {
bomb.destroy();
bombs.splice(i, 1);
}
}
// Clean up dead particles
for (var i = particles.length - 1; i >= 0; i--) {
var particle = particles[i];
if (particle.life <= 0) {
particles.splice(i, 1);
}
}
// Clean up dead knife trails
for (var i = knifeTrails.length - 1; i >= 0; i--) {
var knifeTrail = knifeTrails[i];
if (knifeTrail.life <= 0) {
knifeTrails.splice(i, 1);
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -126,8 +126,63 @@
}
};
return self;
});
+var MainMenu = Container.expand(function () {
+ var self = Container.call(this);
+ // Create menu background
+ var menuBg = self.attachAsset('background', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0,
+ width: 2048,
+ height: 2732
+ });
+ menuBg.tint = 0x2c3e50;
+ // Game title
+ var titleText = new Text2('FRUIT NINJA', {
+ size: 120,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.x = 1024;
+ titleText.y = 800;
+ self.addChild(titleText);
+ // Play button
+ var playButton = self.attachAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1400,
+ width: 400,
+ height: 120
+ });
+ playButton.tint = 0x27ae60;
+ var playText = new Text2('OYNA', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ playText.anchor.set(0.5, 0.5);
+ playText.x = 1024;
+ playText.y = 1400;
+ self.addChild(playText);
+ // High score display
+ var highScoreText = new Text2('En Yüksek Skor: 0', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ highScoreText.anchor.set(0.5, 0.5);
+ highScoreText.x = 1024;
+ highScoreText.y = 1600;
+ self.addChild(highScoreText);
+ // Play button interaction
+ playButton.down = function (x, y, obj) {
+ LK.getSound('touch_sound').play();
+ startGame();
+ };
+ return self;
+});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particleGraphics = self.attachAsset('particle', {
anchorX: 0.5,
@@ -205,17 +260,13 @@
/****
* Game Code
****/
-// Add background image
-var background = game.attachAsset('background', {
- anchorX: 0,
- anchorY: 0,
- x: 0,
- y: 0,
- width: 2048,
- height: 2732
-});
+// Game state variables
+var gameState = 'menu'; // 'menu' or 'playing'
+var mainMenu = null;
+var gameBackground = null;
+// Game arrays and variables
var fruits = [];
var bananas = [];
var strawberries = [];
var bombs = [];
@@ -227,8 +278,38 @@
var lastSliceY = 0;
var comboCount = 0;
var spawnRate = 120;
var gameSpeed = 1;
+// Initialize main menu
+function initMainMenu() {
+ mainMenu = new MainMenu();
+ game.addChild(mainMenu);
+}
+// Start the actual game
+function startGame() {
+ gameState = 'playing';
+ // Remove main menu
+ if (mainMenu) {
+ mainMenu.destroy();
+ mainMenu = null;
+ }
+ // Add game background
+ gameBackground = game.attachAsset('background', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0,
+ width: 2048,
+ height: 2732
+ });
+ // Reset game variables
+ LK.setScore(0);
+ gameSpeed = 1;
+ spawnRate = 120;
+ comboCount = 0;
+}
+// Initialize main menu at start
+initMainMenu();
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
@@ -369,8 +450,9 @@
var distance = Math.sqrt((target.x - closestX) * (target.x - closestX) + (target.y - closestY) * (target.y - closestY));
return distance < 120; // Hit radius
}
game.down = function (x, y, obj) {
+ if (gameState !== 'playing') return;
isSlicing = true;
lastSliceX = x;
lastSliceY = y;
sliceTrail = [{
@@ -381,8 +463,9 @@
// Play touch sound when user starts slicing
LK.getSound('touch_sound').play();
};
game.move = function (x, y, obj) {
+ if (gameState !== 'playing') return;
if (isSlicing) {
// Create knife trails more frequently for denser effect
var distance = Math.sqrt((x - lastSliceX) * (x - lastSliceX) + (y - lastSliceY) * (y - lastSliceY));
if (distance > 8) {
@@ -480,8 +563,9 @@
lastSliceY = y;
}
};
game.up = function (x, y, obj) {
+ if (gameState !== 'playing') return;
isSlicing = false;
sliceTrail = [];
if (comboCount > 1) {
comboTxt.setText('COMBO x' + comboCount + '!');
@@ -497,8 +581,9 @@
}
comboCount = 0;
};
game.update = function () {
+ if (gameState !== 'playing') return;
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
// Increase difficulty over time
if (LK.ticks % 600 === 0) {
Fruit ninja arkaplan. In-Game asset. 2d. High contrast. No shadows
Meyve kesme animasyonu için arkaplan. In-Game asset. 2d. High contrast. No shadows
Muz meyvesi. In-Game asset. 2d. High contrast. No shadows
Çilek. In-Game asset. 2d. High contrast. No shadows
Çilek şeklinde bomba. In-Game asset. 2d. High contrast. No shadows