Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
oyunun kendisinde bir arka plan resmi olsun , oyun başlama menüsünde ise arka plan resmi olsun
User prompt
oyun a ve oyun başlama yerine arka plan resmi ekle
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'stage.addChild(menuScreen);' Line Number: 165
User prompt
oyun başlama menusune arka plan resmi ekle yani demek istediğim şey 2 adet farklı yerler olmalı başlama menusu ve oyunun olduğu yer başlama menusune arka plan resmi ekle mevcut olan oyuna dokunma , oyun başlama menusune START düğmesi ekle ona basıldıgında oyuna gidilsin unutma oyun ve manu farklı yerde olmalı
User prompt
oyuna başlama menüsü ekle ve oyunun başlama menüsüne arka plan resmi ekle 1 adet buton olsun başlama menüsünde START olsun ona basıldığnda oyun başlasın
User prompt
oyuna 4 adet başka fruiet de ekle
User prompt
oyundaki gameovere ses ekle
User prompt
oyuna kesme sesi ekle oyundaki fruiti kesme sesi ve bomb a sesi ekle 2 ses ayrı ayrı olsun
User prompt
oyundaki çizgiler düz olmalı tek çizgi halinde
User prompt
score degeri sola al biraz
Code edit (1 edits merged)
Please save this source code
User prompt
arka plana resim ekle
Code edit (1 edits merged)
Please save this source code
User prompt
Fruit Slash
Initial prompt
bana fruit ninja benzeri bir oyun yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Background = Container.expand(function () {
var self = Container.call(this);
var backgroundGraphics = self.attachAsset('background', {
anchorX: 0,
anchorY: 0
});
self.x = 0;
self.y = 0;
return self;
});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2.5;
self.lastY = 0;
self.update = function () {
self.y += self.speed;
self.rotation += 0.02;
};
return self;
});
var Fruit = Container.expand(function (fruitTypeId) {
var self = Container.call(this);
var fruitAssetId = 'fruit';
if (fruitTypeId === 1) {
fruitAssetId = 'fruit2';
} else if (fruitTypeId === 2) {
fruitAssetId = 'fruit3';
} else if (fruitTypeId === 3) {
fruitAssetId = 'fruit4';
} else if (fruitTypeId === 4) {
fruitAssetId = 'fruit5';
}
var fruitGraphics = self.attachAsset(fruitAssetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.isSliced = false;
self.fruitType = fruitTypeId || 0;
self.lastY = 0;
self.update = function () {
if (!self.isSliced) {
self.y += self.speed;
}
};
self.slice = function () {
self.isSliced = true;
LK.getSound('sliceSound').play();
var leftPiece = game.addChild(new FruitPiece(true));
leftPiece.x = self.x - 20;
leftPiece.y = self.y;
leftPiece.velocityX = -4;
leftPiece.velocityY = -8;
var rightPiece = game.addChild(new FruitPiece(false));
rightPiece.x = self.x + 20;
rightPiece.y = self.y;
rightPiece.velocityX = 4;
rightPiece.velocityY = -8;
LK.effects.flashObject(self, 0xFFFF00, 300);
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
var FruitPiece = Container.expand(function (isLeft) {
var self = Container.call(this);
var piece = self.attachAsset(isLeft ? 'fruitLeft' : 'fruitRight', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.gravity = 0.15;
self.lifespan = 60;
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityY += self.gravity;
self.lifespan--;
if (self.lifespan <= 0) {
self.destroy();
}
};
return self;
});
var SlashEffect = Container.expand(function (x1, y1, x2, y2) {
var self = Container.call(this);
var dx = x2 - x1;
var dy = y2 - y1;
var distance = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx);
var slashLine = self.attachAsset('slashLine', {
anchorX: 0,
anchorY: 0.5
});
self.x = x1;
self.y = y1;
self.rotation = angle;
slashLine.width = distance;
self.lifespan = 200;
slashLine.alpha = 0.8;
self.update = function () {
self.lifespan--;
slashLine.alpha = 0.8 * (self.lifespan / 200);
if (self.lifespan <= 0) {
self.destroy();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1A1A2E
});
/****
* Game Code
****/
var gameStarted = false;
var menuScreen = null;
var gameScreen = null;
var startButton = null;
var gameBackground = null;
function createStartMenu() {
menuScreen = new Container();
game.addChild(menuScreen);
var menuBackground = menuScreen.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
}));
menuBackground.x = 0;
menuBackground.y = 0;
startButton = menuScreen.addChild(new Container());
startButton.x = 2048 / 2;
startButton.y = 2732 / 2;
var buttonShape = startButton.attachAsset('fruit4', {
anchorX: 0.5,
anchorY: 0.5
});
buttonShape.width = 400;
buttonShape.height = 200;
buttonShape.tint = 0x00AA00;
var buttonText = startButton.addChild(new Text2('START', {
size: 120,
fill: '#FFFFFF'
}));
buttonText.anchor.set(0.5, 0.5);
buttonText.x = 0;
buttonText.y = 0;
startButton.interactive = true;
startButton.down = function (x, y, obj) {
startGame();
};
}
function startGame() {
gameStarted = true;
if (menuScreen) {
menuScreen.destroy();
menuScreen = null;
}
gameBackground = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
}));
gameBackground.x = 0;
gameBackground.y = 0;
game.setChildIndex(gameBackground, 0);
gameScreenVisible = true;
}
createStartMenu();
var background = null;
var fruits = [];
var bombs = [];
var pieces = [];
var slashEffects = [];
var gameScreenVisible = false;
var score = 0;
var combo = 0;
var difficulty = 1;
var gameActive = false;
var spawnRate = 60;
var fruitSpeed = 3;
var lastSpawnTick = 0;
var bombChance = 0.15;
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: '#FFFFFF'
});
scoreTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(scoreTxt);
var comboTxt = new Text2('Combo: 0', {
size: 80,
fill: '#FFD700'
});
comboTxt.anchor.set(0.5, 0);
comboTxt.x = 300;
LK.gui.top.addChild(comboTxt);
var difficultyTxt = new Text2('Level: 1', {
size: 70,
fill: '#87CEEB'
});
difficultyTxt.anchor.set(0.5, 0);
difficultyTxt.x = 600;
LK.gui.top.addChild(difficultyTxt);
LK.playMusic('bgmusic', {
loop: true
});
var touchTrail = [];
game.down = function (x, y, obj) {
if (!gameStarted || !gameScreenVisible) {
return;
}
touchTrail = [];
touchTrail.push({
x: x,
y: y
});
var fruitHit = false;
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (!fruit.isSliced) {
var dx = fruit.x - x;
var dy = fruit.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
fruit.slice();
LK.getSound('sliceSound').play();
score += 10 + combo * 5;
combo++;
fruitHit = true;
scoreTxt.setText('Score: ' + score);
comboTxt.setText('Combo: ' + combo);
break;
}
}
}
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
var dx = bomb.x - x;
var dy = bomb.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 50) {
LK.getSound('bombSound').play();
LK.getSound('gameoverSound').play();
LK.effects.flashScreen(0xFF0000, 1000);
gameActive = false;
LK.showGameOver();
}
}
};
game.move = function (x, y, obj) {
if (!gameStarted || !gameScreenVisible || !gameActive) {
return;
}
var lastPoint = touchTrail[touchTrail.length - 1];
if (lastPoint && (Math.abs(x - lastPoint.x) > 5 || Math.abs(y - lastPoint.y) > 5)) {
touchTrail.push({
x: x,
y: y
});
var slashFx = game.addChild(new SlashEffect(lastPoint.x, lastPoint.y, x, y));
slashEffects.push(slashFx);
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (!fruit.isSliced) {
var dx = fruit.x - x;
var dy = fruit.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 70) {
fruit.slice();
LK.getSound('sliceSound').play();
score += 10 + combo * 5;
combo++;
scoreTxt.setText('Score: ' + score);
comboTxt.setText('Combo: ' + combo);
}
}
}
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
var dx = bomb.x - x;
var dy = bomb.y - y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
LK.getSound('bombSound').play();
LK.getSound('gameoverSound').play();
LK.effects.flashScreen(0xFF0000, 1000);
gameActive = false;
LK.showGameOver();
}
}
}
};
game.update = function () {
if (!gameStarted) {
return;
}
if (!gameScreenVisible) {
gameScreenVisible = true;
}
if (!gameActive && gameStarted) {
gameActive = true;
}
if (LK.ticks % spawnRate === 0) {
var randomX = Math.random() * 1900 + 74;
if (Math.random() < bombChance) {
var newBomb = game.addChild(new Bomb());
newBomb.x = randomX;
newBomb.y = -50;
newBomb.speed = fruitSpeed - 0.5;
bombs.push(newBomb);
} else {
var fruitTypeId = Math.floor(Math.random() * 5);
var newFruit = game.addChild(new Fruit(fruitTypeId));
newFruit.x = randomX;
newFruit.y = -50;
newFruit.speed = fruitSpeed;
fruits.push(newFruit);
}
}
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (fruit.lastY === undefined) {
fruit.lastY = fruit.y;
}
if (fruit.lastY >= 0 && fruit.y >= 2732) {
if (!fruit.isSliced) {
combo = 0;
comboTxt.setText('Combo: 0');
LK.effects.flashScreen(0xFF0000, 800);
LK.getSound('gameoverSound').play();
gameActive = false;
LK.showGameOver();
return;
}
}
fruit.lastY = fruit.y;
}
for (var i = bombs.length - 1; i >= 0; i--) {
var bomb = bombs[i];
if (bomb.y >= 2732) {
bomb.destroy();
bombs.splice(i, 1);
}
}
for (var i = pieces.length - 1; i >= 0; i--) {
if (pieces[i].lifespan <= 0) {
pieces.splice(i, 1);
}
}
for (var i = slashEffects.length - 1; i >= 0; i--) {
if (slashEffects[i].lifespan <= 0) {
slashEffects.splice(i, 1);
}
}
if (LK.ticks % 300 === 0) {
difficulty = Math.floor(score / 100) + 1;
spawnRate = Math.max(30, 60 - difficulty * 3);
fruitSpeed = 3 + difficulty * 0.5;
bombChance = Math.min(0.25, 0.15 + difficulty * 0.02);
difficultyTxt.setText('Level: ' + difficulty);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -4,8 +4,132 @@
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
+* Classes
+****/
+var Background = Container.expand(function () {
+ var self = Container.call(this);
+ var backgroundGraphics = self.attachAsset('background', {
+ anchorX: 0,
+ anchorY: 0
+ });
+ self.x = 0;
+ self.y = 0;
+ return self;
+});
+var Bomb = Container.expand(function () {
+ var self = Container.call(this);
+ var bombGraphics = self.attachAsset('bomb', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2.5;
+ self.lastY = 0;
+ self.update = function () {
+ self.y += self.speed;
+ self.rotation += 0.02;
+ };
+ return self;
+});
+var Fruit = Container.expand(function (fruitTypeId) {
+ var self = Container.call(this);
+ var fruitAssetId = 'fruit';
+ if (fruitTypeId === 1) {
+ fruitAssetId = 'fruit2';
+ } else if (fruitTypeId === 2) {
+ fruitAssetId = 'fruit3';
+ } else if (fruitTypeId === 3) {
+ fruitAssetId = 'fruit4';
+ } else if (fruitTypeId === 4) {
+ fruitAssetId = 'fruit5';
+ }
+ var fruitGraphics = self.attachAsset(fruitAssetId, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 3;
+ self.isSliced = false;
+ self.fruitType = fruitTypeId || 0;
+ self.lastY = 0;
+ self.update = function () {
+ if (!self.isSliced) {
+ self.y += self.speed;
+ }
+ };
+ self.slice = function () {
+ self.isSliced = true;
+ LK.getSound('sliceSound').play();
+ var leftPiece = game.addChild(new FruitPiece(true));
+ leftPiece.x = self.x - 20;
+ leftPiece.y = self.y;
+ leftPiece.velocityX = -4;
+ leftPiece.velocityY = -8;
+ var rightPiece = game.addChild(new FruitPiece(false));
+ rightPiece.x = self.x + 20;
+ rightPiece.y = self.y;
+ rightPiece.velocityX = 4;
+ rightPiece.velocityY = -8;
+ LK.effects.flashObject(self, 0xFFFF00, 300);
+ tween(self, {
+ alpha: 0
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ };
+ return self;
+});
+var FruitPiece = Container.expand(function (isLeft) {
+ var self = Container.call(this);
+ var piece = self.attachAsset(isLeft ? 'fruitLeft' : 'fruitRight', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocityX = 0;
+ self.velocityY = 0;
+ self.gravity = 0.15;
+ self.lifespan = 60;
+ self.update = function () {
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ self.velocityY += self.gravity;
+ self.lifespan--;
+ if (self.lifespan <= 0) {
+ self.destroy();
+ }
+ };
+ return self;
+});
+var SlashEffect = Container.expand(function (x1, y1, x2, y2) {
+ var self = Container.call(this);
+ var dx = x2 - x1;
+ var dy = y2 - y1;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ var angle = Math.atan2(dy, dx);
+ var slashLine = self.attachAsset('slashLine', {
+ anchorX: 0,
+ anchorY: 0.5
+ });
+ self.x = x1;
+ self.y = y1;
+ self.rotation = angle;
+ slashLine.width = distance;
+ self.lifespan = 200;
+ slashLine.alpha = 0.8;
+ self.update = function () {
+ self.lifespan--;
+ slashLine.alpha = 0.8 * (self.lifespan / 200);
+ if (self.lifespan <= 0) {
+ self.destroy();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1A1A2E
@@ -13,62 +137,249 @@
/****
* Game Code
****/
-/* MENÜ ARKA PLAN */
-/* OYUN İÇİ ARKA PLAN */
-/****
-* GAME MENU
-****/
var gameStarted = false;
var menuScreen = null;
+var gameScreen = null;
+var startButton = null;
var gameBackground = null;
function createStartMenu() {
menuScreen = new Container();
game.addChild(menuScreen);
- /* MENÜ ARKA PLAN */
- var menuBg = menuScreen.addChild(LK.getAsset('menuBackground', {
+ var menuBackground = menuScreen.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
}));
- menuBg.x = 0;
- menuBg.y = 0;
- var startButton = menuScreen.addChild(new Container());
- startButton.x = 1024;
- startButton.y = 1366;
- var btn = startButton.attachAsset('fruit4', {
+ menuBackground.x = 0;
+ menuBackground.y = 0;
+ startButton = menuScreen.addChild(new Container());
+ startButton.x = 2048 / 2;
+ startButton.y = 2732 / 2;
+ var buttonShape = startButton.attachAsset('fruit4', {
anchorX: 0.5,
anchorY: 0.5
});
- btn.width = 450;
- btn.height = 220;
- btn.tint = 0x00aa00;
- var txt = startButton.addChild(new Text2("START", {
+ buttonShape.width = 400;
+ buttonShape.height = 200;
+ buttonShape.tint = 0x00AA00;
+ var buttonText = startButton.addChild(new Text2('START', {
size: 120,
- fill: 0xFFFFFF
+ fill: '#FFFFFF'
}));
- txt.anchor.set(0.5, 0.5);
+ buttonText.anchor.set(0.5, 0.5);
+ buttonText.x = 0;
+ buttonText.y = 0;
startButton.interactive = true;
- startButton.down = function () {
+ startButton.down = function (x, y, obj) {
startGame();
};
}
function startGame() {
gameStarted = true;
- menuScreen.destroy();
- /* OYUN İÇİ ARKA PLAN */
+ if (menuScreen) {
+ menuScreen.destroy();
+ menuScreen = null;
+ }
gameBackground = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
}));
gameBackground.x = 0;
gameBackground.y = 0;
game.setChildIndex(gameBackground, 0);
+ gameScreenVisible = true;
}
-/* MENÜYÜ BAŞLAT */
createStartMenu();
-/****
-* GAME START
-****/
+var background = null;
+var fruits = [];
+var bombs = [];
+var pieces = [];
+var slashEffects = [];
+var gameScreenVisible = false;
+var score = 0;
+var combo = 0;
+var difficulty = 1;
+var gameActive = false;
+var spawnRate = 60;
+var fruitSpeed = 3;
+var lastSpawnTick = 0;
+var bombChance = 0.15;
+var scoreTxt = new Text2('Score: 0', {
+ size: 100,
+ fill: '#FFFFFF'
+});
+scoreTxt.anchor.set(0, 0);
+LK.gui.topLeft.addChild(scoreTxt);
+var comboTxt = new Text2('Combo: 0', {
+ size: 80,
+ fill: '#FFD700'
+});
+comboTxt.anchor.set(0.5, 0);
+comboTxt.x = 300;
+LK.gui.top.addChild(comboTxt);
+var difficultyTxt = new Text2('Level: 1', {
+ size: 70,
+ fill: '#87CEEB'
+});
+difficultyTxt.anchor.set(0.5, 0);
+difficultyTxt.x = 600;
+LK.gui.top.addChild(difficultyTxt);
LK.playMusic('bgmusic', {
loop: true
-});
\ No newline at end of file
+});
+var touchTrail = [];
+game.down = function (x, y, obj) {
+ if (!gameStarted || !gameScreenVisible) {
+ return;
+ }
+ touchTrail = [];
+ touchTrail.push({
+ x: x,
+ y: y
+ });
+ var fruitHit = false;
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ var fruit = fruits[i];
+ if (!fruit.isSliced) {
+ var dx = fruit.x - x;
+ var dy = fruit.y - y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 60) {
+ fruit.slice();
+ LK.getSound('sliceSound').play();
+ score += 10 + combo * 5;
+ combo++;
+ fruitHit = true;
+ scoreTxt.setText('Score: ' + score);
+ comboTxt.setText('Combo: ' + combo);
+ break;
+ }
+ }
+ }
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ var bomb = bombs[i];
+ var dx = bomb.x - x;
+ var dy = bomb.y - y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 50) {
+ LK.getSound('bombSound').play();
+ LK.getSound('gameoverSound').play();
+ LK.effects.flashScreen(0xFF0000, 1000);
+ gameActive = false;
+ LK.showGameOver();
+ }
+ }
+};
+game.move = function (x, y, obj) {
+ if (!gameStarted || !gameScreenVisible || !gameActive) {
+ return;
+ }
+ var lastPoint = touchTrail[touchTrail.length - 1];
+ if (lastPoint && (Math.abs(x - lastPoint.x) > 5 || Math.abs(y - lastPoint.y) > 5)) {
+ touchTrail.push({
+ x: x,
+ y: y
+ });
+ var slashFx = game.addChild(new SlashEffect(lastPoint.x, lastPoint.y, x, y));
+ slashEffects.push(slashFx);
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ var fruit = fruits[i];
+ if (!fruit.isSliced) {
+ var dx = fruit.x - x;
+ var dy = fruit.y - y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 70) {
+ fruit.slice();
+ LK.getSound('sliceSound').play();
+ score += 10 + combo * 5;
+ combo++;
+ scoreTxt.setText('Score: ' + score);
+ comboTxt.setText('Combo: ' + combo);
+ }
+ }
+ }
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ var bomb = bombs[i];
+ var dx = bomb.x - x;
+ var dy = bomb.y - y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 60) {
+ LK.getSound('bombSound').play();
+ LK.getSound('gameoverSound').play();
+ LK.effects.flashScreen(0xFF0000, 1000);
+ gameActive = false;
+ LK.showGameOver();
+ }
+ }
+ }
+};
+game.update = function () {
+ if (!gameStarted) {
+ return;
+ }
+ if (!gameScreenVisible) {
+ gameScreenVisible = true;
+ }
+ if (!gameActive && gameStarted) {
+ gameActive = true;
+ }
+ if (LK.ticks % spawnRate === 0) {
+ var randomX = Math.random() * 1900 + 74;
+ if (Math.random() < bombChance) {
+ var newBomb = game.addChild(new Bomb());
+ newBomb.x = randomX;
+ newBomb.y = -50;
+ newBomb.speed = fruitSpeed - 0.5;
+ bombs.push(newBomb);
+ } else {
+ var fruitTypeId = Math.floor(Math.random() * 5);
+ var newFruit = game.addChild(new Fruit(fruitTypeId));
+ newFruit.x = randomX;
+ newFruit.y = -50;
+ newFruit.speed = fruitSpeed;
+ fruits.push(newFruit);
+ }
+ }
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ var fruit = fruits[i];
+ if (fruit.lastY === undefined) {
+ fruit.lastY = fruit.y;
+ }
+ if (fruit.lastY >= 0 && fruit.y >= 2732) {
+ if (!fruit.isSliced) {
+ combo = 0;
+ comboTxt.setText('Combo: 0');
+ LK.effects.flashScreen(0xFF0000, 800);
+ LK.getSound('gameoverSound').play();
+ gameActive = false;
+ LK.showGameOver();
+ return;
+ }
+ }
+ fruit.lastY = fruit.y;
+ }
+ for (var i = bombs.length - 1; i >= 0; i--) {
+ var bomb = bombs[i];
+ if (bomb.y >= 2732) {
+ bomb.destroy();
+ bombs.splice(i, 1);
+ }
+ }
+ for (var i = pieces.length - 1; i >= 0; i--) {
+ if (pieces[i].lifespan <= 0) {
+ pieces.splice(i, 1);
+ }
+ }
+ for (var i = slashEffects.length - 1; i >= 0; i--) {
+ if (slashEffects[i].lifespan <= 0) {
+ slashEffects.splice(i, 1);
+ }
+ }
+ if (LK.ticks % 300 === 0) {
+ difficulty = Math.floor(score / 100) + 1;
+ spawnRate = Math.max(30, 60 - difficulty * 3);
+ fruitSpeed = 3 + difficulty * 0.5;
+ bombChance = Math.min(0.25, 0.15 + difficulty * 0.02);
+ difficultyTxt.setText('Level: ' + difficulty);
+ }
+};
\ No newline at end of file