/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Fruit = Container.expand(function () {
var self = Container.call(this);
self.fruitType = 0;
self.velocity = {
x: 0,
y: 0
};
self.isMoving = false;
self.mergeCount = 0;
var fruitAssets = ['cherry', 'strawberry', 'orange', 'lemon', 'peach', 'apple', 'pineapple', 'coconut', 'pomegranate', 'melon', 'watermelon'];
self.initialize = function (fruitType) {
self.fruitType = fruitType;
var assetId = fruitAssets[fruitType];
var graphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.width = graphics.width;
self.height = graphics.height;
self.velocity = {
x: 0,
y: 0
};
self.isMoving = false;
self.mergeCount = 0;
self.isMerging = false;
self.lastX = self.x; //{collision_track_1}
self.lastY = self.y; //{collision_track_2}
self.lastWasColliding = false; //{collision_track_3}
};
self.applyPhysics = function () {
self.lastX = self.x; //{collision_track_4}
self.lastY = self.y; //{collision_track_5}
self.velocity.y += 0.45;
if (self.velocity.y > 18) {
self.velocity.y = 18;
}
self.x += self.velocity.x;
self.y += self.velocity.y;
self.velocity.x *= 0.92;
self.velocity.y *= 0.96;
if (self.x - self.width / 2 < 260) {
self.x = 260 + self.width / 2;
self.velocity.x = Math.abs(self.velocity.x) * -0.6;
}
if (self.x + self.width / 2 > 1788) {
self.x = 1788 - self.width / 2;
self.velocity.x = -Math.abs(self.velocity.x) * 0.6;
}
if (self.y + self.height / 2 > 2550) {
self.y = 2550 - self.height / 2;
self.velocity.y *= -0.2;
if (Math.abs(self.velocity.y) < 0.2) {
self.velocity.y = 0;
}
}
if (Math.abs(self.velocity.y) < 0.3 && Math.abs(self.velocity.x) < 0.3) {
self.isMoving = false;
self.isMerging = false;
} else {
self.isMoving = true;
}
};
self.update = function () {
if (self.isMoving) {
self.applyPhysics();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFAF8F3
});
/****
* Game Code
****/
var fruits = [];
var nextFruitType = 0;
var score = 0;
var deadzoneTimer = 0;
var gameOver = false;
var draggedFruit = null;
var dragOffsetX = 0;
var combo = 0;
var comboTimeout = null;
var containerLeft = 200;
var containerRight = 1848;
var containerTop = 200;
var containerBottom = 2600;
var deadzoneTop = 150;
var deadzoneBottom = 230;
// Glass container visuals
var glassLeft = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5,
width: 120,
height: 2400
});
glassLeft.x = 200;
glassLeft.y = 1400;
glassLeft.alpha = 0.15;
game.addChild(glassLeft);
var glassRight = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5,
width: 120,
height: 2400
});
glassRight.x = 1848;
glassRight.y = 1400;
glassRight.alpha = 0.15;
game.addChild(glassRight);
var glassBottom = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5,
width: 1648,
height: 120
});
glassBottom.x = 1024;
glassBottom.y = 2600;
glassBottom.alpha = 0.15;
game.addChild(glassBottom);
var fruitData = [{
name: 'Cherry',
color: 0xDC143C,
size: 80
}, {
name: 'Strawberry',
color: 0xFF1744,
size: 95
}, {
name: 'Orange',
color: 0xFF8C00,
size: 110
}, {
name: 'Lemon',
color: 0xFFD700,
size: 125
}, {
name: 'Peach',
color: 0xFFB347,
size: 140
}, {
name: 'Apple',
color: 0xE53935,
size: 155
}, {
name: 'Pineapple',
color: 0xFDD835,
size: 170
}, {
name: 'Coconut',
color: 0x8B7355,
size: 185
}, {
name: 'Pomegranate',
color: 0xC41E3A,
size: 200
}, {
name: 'Melon',
color: 0xA4DE6C,
size: 215
}, {
name: 'Watermelon',
color: 0x228B22,
size: 230
}];
function getRandomFruit() {
var maxFruit = 5;
return Math.floor(Math.random() * maxFruit);
}
function createFruit(type) {
var newFruit = new Fruit();
newFruit.initialize(type);
newFruit.x = 1024;
newFruit.y = containerTop + 50;
newFruit.velocity = {
x: 0,
y: 0
};
newFruit.isMoving = true;
newFruit.lastWasIntersecting = false;
game.addChild(newFruit);
fruits.push(newFruit);
return newFruit;
}
function mergeFruits(fruit1, fruit2) {
if (fruit1.fruitType !== fruit2.fruitType || fruit1.fruitType >= 10) {
return;
}
var mergeType = fruit1.fruitType + 1;
var mergeX = (fruit1.x + fruit2.x) / 2;
var mergeY = (fruit1.y + fruit2.y) / 2;
var fruit1Index = fruits.indexOf(fruit1);
var fruit2Index = fruits.indexOf(fruit2);
if (fruit1Index > -1) {
fruit1.destroy();
fruits.splice(fruit1Index, 1);
}
if (fruit2Index > -1) {
fruit2.destroy();
fruits.splice(fruit2Index, 1);
}
var newFruit = createFruit(mergeType);
newFruit.x = mergeX;
newFruit.y = mergeY;
newFruit.velocity = {
x: 0,
y: 0
};
newFruit.isMoving = true;
newFruit.isMerging = false;
newFruit.mergeCount = Math.max(fruit1.mergeCount, fruit2.mergeCount) + 1;
LK.getSound('merge').play();
var points = (mergeType + 1) * 10 * (combo + 1);
score += points;
combo++;
if (comboTimeout) {
LK.clearTimeout(comboTimeout);
}
comboTimeout = LK.setTimeout(function () {
combo = 0;
}, 1000);
scoreTxt.setText('Score: ' + score);
if (mergeType === 10) {
LK.showYouWin();
}
}
function checkCollisionsAndMerges() {
for (var i = 0; i < fruits.length; i++) {
for (var j = i + 1; j < fruits.length; j++) {
var f1 = fruits[i];
var f2 = fruits[j];
if (f1 && f2) {
var dx = f1.x - f2.x;
var dy = f1.y - f2.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var minDistance = (f1.width + f2.width) / 2;
var isColliding = distance < minDistance;
if (f1.lastWasColliding === undefined) f1.lastWasColliding = false;
if (f2.lastWasColliding === undefined) f2.lastWasColliding = false;
if (isColliding && distance > 0) {
var overlap = minDistance - distance + 2;
var angle = Math.atan2(dy, dx);
var moveX = overlap / 2 * Math.cos(angle);
var moveY = overlap / 2 * Math.sin(angle);
f1.x += moveX;
f1.y += moveY;
f2.x -= moveX;
f2.y -= moveY;
f1.velocity.x = f1.velocity.x * 0.8 + Math.cos(angle) * 0.5;
f2.velocity.x = f2.velocity.x * 0.8 - Math.cos(angle) * 0.5;
} //{collision_track_6}
var isIntersecting = distance < minDistance * 0.85 && f1.fruitType === f2.fruitType;
if (f1.lastWasIntersecting === undefined) f1.lastWasIntersecting = false;
if (f2.lastWasIntersecting === undefined) f2.lastWasIntersecting = false;
if (f1.isMerging === undefined) f1.isMerging = false;
if (f2.isMerging === undefined) f2.isMerging = false;
if (!f1.lastWasIntersecting && isIntersecting && !f1.isMerging && !f2.isMerging) {
f1.isMerging = true;
f2.isMerging = true;
mergeFruits(f1, f2);
return true;
}
f1.lastWasIntersecting = isIntersecting;
f2.lastWasIntersecting = isIntersecting;
f1.lastWasColliding = isColliding;
f2.lastWasColliding = isColliding;
}
}
}
return false;
}
function updateDeadzone() {
var fruitsInDeadzone = 0;
for (var i = 0; i < fruits.length; i++) {
if (fruits[i].y - fruits[i].height / 2 < deadzoneBottom) {
fruitsInDeadzone++;
}
}
if (fruitsInDeadzone > 0) {
deadzoneTimer++;
if (deadzoneTimer > 180) {
gameOver = true;
LK.getSound('gameover').play();
LK.showGameOver();
}
} else {
deadzoneTimer = 0;
}
}
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: '#333333'
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.x = 1024;
scoreTxt.y = 10;
LK.gui.top.addChild(scoreTxt);
var deadzoneTimerTxt = new Text2('Safe: 0s', {
size: 60,
fill: '#228b22'
});
deadzoneTimerTxt.anchor.set(0.5, 0);
deadzoneTimerTxt.x = 1024;
deadzoneTimerTxt.y = 120;
LK.gui.top.addChild(deadzoneTimerTxt);
// Fruit progression display
var progressionContainer = new Container();
var progressionTitle = new Text2('Fruit Evolution Chain', {
size: 40,
fill: '#333333'
});
progressionTitle.anchor.set(0.5, 0);
progressionTitle.x = 1024;
progressionTitle.y = 50;
progressionContainer.addChild(progressionTitle);
// Display fruit progression in rows
var fruitDisplayWidth = 150;
var fruitDisplayHeight = 80;
var fruitsPerRow = 6;
var progressionStartY = 150;
var progressionStartX = 200;
for (var fIdx = 0; fIdx < fruitData.length; fIdx++) {
var row = Math.floor(fIdx / fruitsPerRow);
var col = fIdx % fruitsPerRow;
var displayX = progressionStartX + col * fruitDisplayWidth + 60;
var displayY = progressionStartY + row * fruitDisplayHeight + 40;
var fruitLabel = new Text2(fIdx + 1 + '. ' + fruitData[fIdx].name, {
size: 32,
fill: '#666666'
});
fruitLabel.anchor.set(0.5, 0.5);
fruitLabel.x = displayX;
fruitLabel.y = displayY;
progressionContainer.addChild(fruitLabel);
}
game.addChild(progressionContainer);
var nextFruitTxt = new Text2('Next: ' + fruitData[nextFruitType].name, {
size: 60,
fill: '#666666'
});
nextFruitTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(nextFruitTxt);
nextFruitType = getRandomFruit();
var deadzoneVisual = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5
});
deadzoneVisual.x = 1024;
deadzoneVisual.y = 190;
deadzoneVisual.alpha = 0.5;
deadzoneVisual.tint = 0xff6b6b;
game.addChild(deadzoneVisual);
var deadzoneLabel = new Text2('DANGER ZONE', {
size: 40,
fill: '#ff0000'
});
deadzoneLabel.anchor.set(0.5, 0.5);
deadzoneLabel.x = 1024;
deadzoneLabel.y = 190;
game.addChild(deadzoneLabel);
game.down = function (x, y, obj) {
if (!gameOver && !draggedFruit) {
draggedFruit = createFruit(nextFruitType);
dragOffsetX = x - draggedFruit.x;
draggedFruit.velocity = {
x: 0,
y: 0
};
draggedFruit.isMoving = true;
nextFruitType = getRandomFruit();
nextFruitTxt.setText('Next: ' + fruitData[nextFruitType].name);
LK.getSound('drop').play();
}
};
game.move = function (x, y, obj) {
if (draggedFruit) {
draggedFruit.x = Math.max(containerLeft + draggedFruit.width / 2, Math.min(containerRight - draggedFruit.width / 2, x - dragOffsetX));
draggedFruit.y = containerTop + 50;
draggedFruit.velocity = {
x: 0,
y: 0
};
}
};
game.up = function (x, y, obj) {
if (draggedFruit) {
draggedFruit.velocity = {
x: 0,
y: 2
};
draggedFruit.isMoving = true;
draggedFruit = null;
}
};
game.update = function () {
if (gameOver) return;
for (var i = 0; i < fruits.length; i++) {
var fruit = fruits[i];
if (fruit && fruit.update) {
fruit.update();
}
}
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (fruit.y > containerBottom + 500) {
fruit.destroy();
fruits.splice(i, 1);
}
}
var mergedThisFrame = true;
while (mergedThisFrame) {
mergedThisFrame = checkCollisionsAndMerges();
}
updateDeadzone();
var secondsRemaining = Math.max(0, Math.ceil((180 - deadzoneTimer) / 60));
if (deadzoneTimer > 0) {
deadzoneTimerTxt.setText('Danger: ' + secondsRemaining + 's');
deadzoneTimerTxt.tint = deadzoneTimer > 120 ? 0xff0000 : 0xff9900;
} else {
deadzoneTimerTxt.setText('Safe: 0s');
deadzoneTimerTxt.tint = 0x228b22;
}
};
LK.playMusic('bgmusic'); /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Fruit = Container.expand(function () {
var self = Container.call(this);
self.fruitType = 0;
self.velocity = {
x: 0,
y: 0
};
self.isMoving = false;
self.mergeCount = 0;
var fruitAssets = ['cherry', 'strawberry', 'orange', 'lemon', 'peach', 'apple', 'pineapple', 'coconut', 'pomegranate', 'melon', 'watermelon'];
self.initialize = function (fruitType) {
self.fruitType = fruitType;
var assetId = fruitAssets[fruitType];
var graphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.width = graphics.width;
self.height = graphics.height;
self.velocity = {
x: 0,
y: 0
};
self.isMoving = false;
self.mergeCount = 0;
self.isMerging = false;
self.lastX = self.x; //{collision_track_1}
self.lastY = self.y; //{collision_track_2}
self.lastWasColliding = false; //{collision_track_3}
};
self.applyPhysics = function () {
self.lastX = self.x; //{collision_track_4}
self.lastY = self.y; //{collision_track_5}
self.velocity.y += 0.45;
if (self.velocity.y > 18) {
self.velocity.y = 18;
}
self.x += self.velocity.x;
self.y += self.velocity.y;
self.velocity.x *= 0.92;
self.velocity.y *= 0.96;
if (self.x - self.width / 2 < 260) {
self.x = 260 + self.width / 2;
self.velocity.x = Math.abs(self.velocity.x) * -0.6;
}
if (self.x + self.width / 2 > 1788) {
self.x = 1788 - self.width / 2;
self.velocity.x = -Math.abs(self.velocity.x) * 0.6;
}
if (self.y + self.height / 2 > 2550) {
self.y = 2550 - self.height / 2;
self.velocity.y *= -0.2;
if (Math.abs(self.velocity.y) < 0.2) {
self.velocity.y = 0;
}
}
if (Math.abs(self.velocity.y) < 0.3 && Math.abs(self.velocity.x) < 0.3) {
self.isMoving = false;
self.isMerging = false;
} else {
self.isMoving = true;
}
};
self.update = function () {
if (self.isMoving) {
self.applyPhysics();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFAF8F3
});
/****
* Game Code
****/
var fruits = [];
var nextFruitType = 0;
var score = 0;
var deadzoneTimer = 0;
var gameOver = false;
var draggedFruit = null;
var dragOffsetX = 0;
var combo = 0;
var comboTimeout = null;
var containerLeft = 200;
var containerRight = 1848;
var containerTop = 200;
var containerBottom = 2600;
var deadzoneTop = 150;
var deadzoneBottom = 230;
// Glass container visuals
var glassLeft = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5,
width: 120,
height: 2400
});
glassLeft.x = 200;
glassLeft.y = 1400;
glassLeft.alpha = 0.15;
game.addChild(glassLeft);
var glassRight = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5,
width: 120,
height: 2400
});
glassRight.x = 1848;
glassRight.y = 1400;
glassRight.alpha = 0.15;
game.addChild(glassRight);
var glassBottom = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5,
width: 1648,
height: 120
});
glassBottom.x = 1024;
glassBottom.y = 2600;
glassBottom.alpha = 0.15;
game.addChild(glassBottom);
var fruitData = [{
name: 'Cherry',
color: 0xDC143C,
size: 80
}, {
name: 'Strawberry',
color: 0xFF1744,
size: 95
}, {
name: 'Orange',
color: 0xFF8C00,
size: 110
}, {
name: 'Lemon',
color: 0xFFD700,
size: 125
}, {
name: 'Peach',
color: 0xFFB347,
size: 140
}, {
name: 'Apple',
color: 0xE53935,
size: 155
}, {
name: 'Pineapple',
color: 0xFDD835,
size: 170
}, {
name: 'Coconut',
color: 0x8B7355,
size: 185
}, {
name: 'Pomegranate',
color: 0xC41E3A,
size: 200
}, {
name: 'Melon',
color: 0xA4DE6C,
size: 215
}, {
name: 'Watermelon',
color: 0x228B22,
size: 230
}];
function getRandomFruit() {
var maxFruit = 5;
return Math.floor(Math.random() * maxFruit);
}
function createFruit(type) {
var newFruit = new Fruit();
newFruit.initialize(type);
newFruit.x = 1024;
newFruit.y = containerTop + 50;
newFruit.velocity = {
x: 0,
y: 0
};
newFruit.isMoving = true;
newFruit.lastWasIntersecting = false;
game.addChild(newFruit);
fruits.push(newFruit);
return newFruit;
}
function mergeFruits(fruit1, fruit2) {
if (fruit1.fruitType !== fruit2.fruitType || fruit1.fruitType >= 10) {
return;
}
var mergeType = fruit1.fruitType + 1;
var mergeX = (fruit1.x + fruit2.x) / 2;
var mergeY = (fruit1.y + fruit2.y) / 2;
var fruit1Index = fruits.indexOf(fruit1);
var fruit2Index = fruits.indexOf(fruit2);
if (fruit1Index > -1) {
fruit1.destroy();
fruits.splice(fruit1Index, 1);
}
if (fruit2Index > -1) {
fruit2.destroy();
fruits.splice(fruit2Index, 1);
}
var newFruit = createFruit(mergeType);
newFruit.x = mergeX;
newFruit.y = mergeY;
newFruit.velocity = {
x: 0,
y: 0
};
newFruit.isMoving = true;
newFruit.isMerging = false;
newFruit.mergeCount = Math.max(fruit1.mergeCount, fruit2.mergeCount) + 1;
LK.getSound('merge').play();
var points = (mergeType + 1) * 10 * (combo + 1);
score += points;
combo++;
if (comboTimeout) {
LK.clearTimeout(comboTimeout);
}
comboTimeout = LK.setTimeout(function () {
combo = 0;
}, 1000);
scoreTxt.setText('Score: ' + score);
if (mergeType === 10) {
LK.showYouWin();
}
}
function checkCollisionsAndMerges() {
for (var i = 0; i < fruits.length; i++) {
for (var j = i + 1; j < fruits.length; j++) {
var f1 = fruits[i];
var f2 = fruits[j];
if (f1 && f2) {
var dx = f1.x - f2.x;
var dy = f1.y - f2.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var minDistance = (f1.width + f2.width) / 2;
var isColliding = distance < minDistance;
if (f1.lastWasColliding === undefined) f1.lastWasColliding = false;
if (f2.lastWasColliding === undefined) f2.lastWasColliding = false;
if (isColliding && distance > 0) {
var overlap = minDistance - distance + 2;
var angle = Math.atan2(dy, dx);
var moveX = overlap / 2 * Math.cos(angle);
var moveY = overlap / 2 * Math.sin(angle);
f1.x += moveX;
f1.y += moveY;
f2.x -= moveX;
f2.y -= moveY;
f1.velocity.x = f1.velocity.x * 0.8 + Math.cos(angle) * 0.5;
f2.velocity.x = f2.velocity.x * 0.8 - Math.cos(angle) * 0.5;
} //{collision_track_6}
var isIntersecting = distance < minDistance * 0.85 && f1.fruitType === f2.fruitType;
if (f1.lastWasIntersecting === undefined) f1.lastWasIntersecting = false;
if (f2.lastWasIntersecting === undefined) f2.lastWasIntersecting = false;
if (f1.isMerging === undefined) f1.isMerging = false;
if (f2.isMerging === undefined) f2.isMerging = false;
if (!f1.lastWasIntersecting && isIntersecting && !f1.isMerging && !f2.isMerging) {
f1.isMerging = true;
f2.isMerging = true;
mergeFruits(f1, f2);
return true;
}
f1.lastWasIntersecting = isIntersecting;
f2.lastWasIntersecting = isIntersecting;
f1.lastWasColliding = isColliding;
f2.lastWasColliding = isColliding;
}
}
}
return false;
}
function updateDeadzone() {
var fruitsInDeadzone = 0;
for (var i = 0; i < fruits.length; i++) {
if (fruits[i].y - fruits[i].height / 2 < deadzoneBottom) {
fruitsInDeadzone++;
}
}
if (fruitsInDeadzone > 0) {
deadzoneTimer++;
if (deadzoneTimer > 180) {
gameOver = true;
LK.getSound('gameover').play();
LK.showGameOver();
}
} else {
deadzoneTimer = 0;
}
}
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: '#333333'
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.x = 1024;
scoreTxt.y = 10;
LK.gui.top.addChild(scoreTxt);
var deadzoneTimerTxt = new Text2('Safe: 0s', {
size: 60,
fill: '#228b22'
});
deadzoneTimerTxt.anchor.set(0.5, 0);
deadzoneTimerTxt.x = 1024;
deadzoneTimerTxt.y = 120;
LK.gui.top.addChild(deadzoneTimerTxt);
// Fruit progression display
var progressionContainer = new Container();
var progressionTitle = new Text2('Fruit Evolution Chain', {
size: 40,
fill: '#333333'
});
progressionTitle.anchor.set(0.5, 0);
progressionTitle.x = 1024;
progressionTitle.y = 50;
progressionContainer.addChild(progressionTitle);
// Display fruit progression in rows
var fruitDisplayWidth = 150;
var fruitDisplayHeight = 80;
var fruitsPerRow = 6;
var progressionStartY = 150;
var progressionStartX = 200;
for (var fIdx = 0; fIdx < fruitData.length; fIdx++) {
var row = Math.floor(fIdx / fruitsPerRow);
var col = fIdx % fruitsPerRow;
var displayX = progressionStartX + col * fruitDisplayWidth + 60;
var displayY = progressionStartY + row * fruitDisplayHeight + 40;
var fruitLabel = new Text2(fIdx + 1 + '. ' + fruitData[fIdx].name, {
size: 32,
fill: '#666666'
});
fruitLabel.anchor.set(0.5, 0.5);
fruitLabel.x = displayX;
fruitLabel.y = displayY;
progressionContainer.addChild(fruitLabel);
}
game.addChild(progressionContainer);
var nextFruitTxt = new Text2('Next: ' + fruitData[nextFruitType].name, {
size: 60,
fill: '#666666'
});
nextFruitTxt.anchor.set(0.5, 0);
LK.gui.topRight.addChild(nextFruitTxt);
nextFruitType = getRandomFruit();
var deadzoneVisual = LK.getAsset('deadzone', {
anchorX: 0.5,
anchorY: 0.5
});
deadzoneVisual.x = 1024;
deadzoneVisual.y = 190;
deadzoneVisual.alpha = 0.5;
deadzoneVisual.tint = 0xff6b6b;
game.addChild(deadzoneVisual);
var deadzoneLabel = new Text2('DANGER ZONE', {
size: 40,
fill: '#ff0000'
});
deadzoneLabel.anchor.set(0.5, 0.5);
deadzoneLabel.x = 1024;
deadzoneLabel.y = 190;
game.addChild(deadzoneLabel);
game.down = function (x, y, obj) {
if (!gameOver && !draggedFruit) {
draggedFruit = createFruit(nextFruitType);
dragOffsetX = x - draggedFruit.x;
draggedFruit.velocity = {
x: 0,
y: 0
};
draggedFruit.isMoving = true;
nextFruitType = getRandomFruit();
nextFruitTxt.setText('Next: ' + fruitData[nextFruitType].name);
LK.getSound('drop').play();
}
};
game.move = function (x, y, obj) {
if (draggedFruit) {
draggedFruit.x = Math.max(containerLeft + draggedFruit.width / 2, Math.min(containerRight - draggedFruit.width / 2, x - dragOffsetX));
draggedFruit.y = containerTop + 50;
draggedFruit.velocity = {
x: 0,
y: 0
};
}
};
game.up = function (x, y, obj) {
if (draggedFruit) {
draggedFruit.velocity = {
x: 0,
y: 2
};
draggedFruit.isMoving = true;
draggedFruit = null;
}
};
game.update = function () {
if (gameOver) return;
for (var i = 0; i < fruits.length; i++) {
var fruit = fruits[i];
if (fruit && fruit.update) {
fruit.update();
}
}
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
if (fruit.y > containerBottom + 500) {
fruit.destroy();
fruits.splice(i, 1);
}
}
var mergedThisFrame = true;
while (mergedThisFrame) {
mergedThisFrame = checkCollisionsAndMerges();
}
updateDeadzone();
var secondsRemaining = Math.max(0, Math.ceil((180 - deadzoneTimer) / 60));
if (deadzoneTimer > 0) {
deadzoneTimerTxt.setText('Danger: ' + secondsRemaining + 's');
deadzoneTimerTxt.tint = deadzoneTimer > 120 ? 0xff0000 : 0xff9900;
} else {
deadzoneTimerTxt.setText('Safe: 0s');
deadzoneTimerTxt.tint = 0x228b22;
}
};
LK.playMusic('bgmusic');
make the apple. In-Game asset. 2d. High contrast. No shadows
make the cherry. In-Game asset. 2d. High contrast. No shadows
make the coconut. In-Game asset. 2d. High contrast. No shadows
make the lemon. In-Game asset. 2d. High contrast. No shadows
make the cantaloupe. In-Game asset. 2d. High contrast. No shadows
make the orange. In-Game asset. 2d. High contrast. No shadows
make the peach. In-Game asset. 2d. High contrast. No shadows
make the pineapple. In-Game asset. 2d. High contrast. No shadows