User prompt
Quitar lag
User prompt
Que el láser al colisionar con una fruta que de experiencia ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Quitar lag
User prompt
Al cortar fruta +2 monedas
User prompt
Pon un botón de volver al menú
User prompt
Pon una mejora que 2 láseres i ser más ancho
User prompt
Añadir tienda ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Añadir un menú de inicio
User prompt
Para acabar tienes que tener 25000
User prompt
Mejoras para el jugador ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Mejoras de puntos
User prompt
Mejoras
Code edit (1 edits merged)
Please save this source code
User prompt
Smash Fruit Frenzy
Initial prompt
Shmas fruite
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
highScore: 0,
totalGamesPlayed: 0,
unlockedSkins: ["default"],
coins: 0,
speedUpgrade: 0,
magnetUpgrade: 0,
multiplierUpgrade: 0,
luckUpgrade: 0,
laserUpgrade: 0
});
/****
* Classes
****/
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
self.updateWidth = function () {
var laserLevel = storage.laserUpgrade || 0;
if (laserLevel > 0) {
characterGraphics.scaleX = 1 + laserLevel * 0.3;
}
};
return self;
});
var Fruit = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'apple';
self.fallSpeed = 3;
self.points = 10;
var fruitGraphics = self.attachAsset(self.type, {
anchorX: 0.5,
anchorY: 0.5
});
// Set different points for different fruits
switch (self.type) {
case 'apple':
self.points = 10;
break;
case 'orange':
self.points = 15;
break;
case 'banana':
self.points = 20;
break;
case 'grape':
self.points = 25;
break;
case 'powerup':
self.points = 50;
self.fallSpeed = 2; // Slower fall speed
break;
}
self.update = function () {
self.y += self.fallSpeed;
};
return self;
});
var Laser = Container.expand(function () {
var self = Container.call(this);
var laserGraphics = self.attachAsset('laser', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -12;
self.update = function () {
self.y += self.speed;
};
return self;
});
var PlayerUpgrade = Container.expand(function () {
var self = Container.call(this);
self.level = 1;
self.experience = 0;
self.experienceToNext = 100;
self.magnetPower = 1;
self.scoreMultiplier = 1;
self.bonusDropChance = 0.05;
self.gainExperience = function (amount) {
self.experience += amount;
if (self.experience >= self.experienceToNext) {
self.levelUp();
}
};
self.levelUp = function () {
self.level++;
self.experience = 0;
self.experienceToNext = 100 + self.level * 50;
self.magnetPower += 0.1;
self.scoreMultiplier += 0.1;
self.bonusDropChance += 0.01;
// Show level up effect
LK.effects.flashScreen(0x00FF00, 500);
// Update storage
storage.playerLevel = self.level;
storage.playerExperience = self.experience;
};
self.loadFromStorage = function () {
self.level = storage.playerLevel || 1;
self.experience = storage.playerExperience || 0;
self.experienceToNext = 100 + self.level * 50;
self.magnetPower = 1 + (self.level - 1) * 0.1;
self.scoreMultiplier = 1 + (self.level - 1) * 0.1;
self.bonusDropChance = 0.05 + (self.level - 1) * 0.01;
};
return self;
});
var Shop = Container.expand(function () {
var self = Container.call(this);
// Background overlay
var overlay = LK.getAsset('character', {
anchorX: 0,
anchorY: 0,
scaleX: 17,
scaleY: 23,
alpha: 0.9,
tint: 0x000066
});
self.addChild(overlay);
// Title text
var titleTxt = new Text2('SHOP', {
size: 120,
fill: 0xFFD700
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.x = 2048 / 2;
titleTxt.y = 400;
self.addChild(titleTxt);
// Coins display
var coinsTxt = new Text2('Coins: ' + (storage.coins || 0), {
size: 60,
fill: 0xFFFFFF
});
coinsTxt.anchor.set(0.5, 0.5);
coinsTxt.x = 2048 / 2;
coinsTxt.y = 500;
self.addChild(coinsTxt);
// Shop items
var shopItems = [{
name: 'Speed Boost',
price: 100,
description: 'Faster character movement',
type: 'speed'
}, {
name: 'Magnet Power',
price: 150,
description: 'Stronger fruit attraction',
type: 'magnet'
}, {
name: 'Score Multiplier',
price: 200,
description: 'More points per fruit',
type: 'multiplier'
}, {
name: 'Lucky Chance',
price: 250,
description: 'More power-up fruits',
type: 'luck'
}, {
name: 'Laser System',
price: 300,
description: 'Wider character + dual lasers',
type: 'laser'
}];
var itemY = 650;
for (var i = 0; i < shopItems.length; i++) {
var item = shopItems[i];
// Item background
var itemBg = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 8,
scaleY: 1.2,
tint: 0x333333
});
itemBg.x = 2048 / 2;
itemBg.y = itemY;
itemBg.itemData = item;
self.addChild(itemBg);
// Item name
var itemName = new Text2(item.name, {
size: 50,
fill: 0xFFFFFF
});
itemName.anchor.set(0, 0.5);
itemName.x = 300;
itemName.y = itemY;
self.addChild(itemName);
// Item price
var itemPrice = new Text2(item.price + ' coins', {
size: 40,
fill: 0xFFD700
});
itemPrice.anchor.set(1, 0.5);
itemPrice.x = 1400;
itemPrice.y = itemY;
self.addChild(itemPrice);
// Buy button
var buyBtn = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 0.8,
tint: 0x00AA00
});
buyBtn.x = 1600;
buyBtn.y = itemY;
buyBtn.itemData = item;
self.addChild(buyBtn);
var buyTxt = new Text2('BUY', {
size: 35,
fill: 0xFFFFFF
});
buyTxt.anchor.set(0.5, 0.5);
buyTxt.x = 1600;
buyTxt.y = itemY;
buyTxt.itemData = item;
self.addChild(buyTxt);
// Buy button handler
buyBtn.down = function (x, y, obj) {
self.buyItem(this.itemData);
};
buyTxt.down = function (x, y, obj) {
self.buyItem(this.itemData);
};
itemY += 200;
}
// Close button
var closeBtn = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1,
tint: 0xFF4444
});
closeBtn.x = 2048 / 2;
closeBtn.y = 2200;
self.addChild(closeBtn);
var closeTxt = new Text2('CLOSE', {
size: 60,
fill: 0xFFFFFF
});
closeTxt.anchor.set(0.5, 0.5);
closeTxt.x = 2048 / 2;
closeTxt.y = 2200;
self.addChild(closeTxt);
closeBtn.down = function (x, y, obj) {
self.hide();
};
closeTxt.down = function (x, y, obj) {
self.hide();
};
self.buyItem = function (item) {
var currentCoins = storage.coins || 0;
if (currentCoins >= item.price) {
storage.coins = currentCoins - item.price;
// Apply upgrade
switch (item.type) {
case 'speed':
storage.speedUpgrade = (storage.speedUpgrade || 0) + 1;
break;
case 'magnet':
storage.magnetUpgrade = (storage.magnetUpgrade || 0) + 1;
break;
case 'multiplier':
storage.multiplierUpgrade = (storage.multiplierUpgrade || 0) + 1;
break;
case 'luck':
storage.luckUpgrade = (storage.luckUpgrade || 0) + 1;
break;
case 'laser':
storage.laserUpgrade = (storage.laserUpgrade || 0) + 1;
break;
}
// Update coins display
coinsTxt.setText('Coins: ' + storage.coins);
// Flash success
LK.effects.flashScreen(0x00FF00, 300);
} else {
// Flash failure
LK.effects.flashScreen(0xFF0000, 300);
}
};
self.hide = function () {
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
}
});
};
self.show = function () {
self.visible = true;
self.alpha = 0;
coinsTxt.setText('Coins: ' + (storage.coins || 0));
tween(self, {
alpha: 1
}, {
duration: 300
});
};
self.visible = false;
return self;
});
// Music will be started by the menu
var StartMenu = Container.expand(function () {
var self = Container.call(this);
// Background overlay
var overlay = LK.getAsset('character', {
anchorX: 0,
anchorY: 0,
scaleX: 17,
scaleY: 23,
alpha: 0.8,
tint: 0x000000
});
self.addChild(overlay);
// Title text
var titleTxt = new Text2('SMASH FRUIT FRENZY', {
size: 120,
fill: 0xFFD700
});
titleTxt.anchor.set(0.5, 0.5);
titleTxt.x = 2048 / 2;
titleTxt.y = 800;
self.addChild(titleTxt);
// Start button
var startButton = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 1.5,
tint: 0x00FF00
});
startButton.x = 2048 / 2;
startButton.y = 1400;
self.addChild(startButton);
var startTxt = new Text2('START GAME', {
size: 80,
fill: 0xFFFFFF
});
startTxt.anchor.set(0.5, 0.5);
startTxt.x = 2048 / 2;
startTxt.y = 1400;
self.addChild(startTxt);
// High score display
var menuHighScoreTxt = new Text2('Best Score: ' + (storage.highScore || 0), {
size: 60,
fill: 0xFFFFFF
});
menuHighScoreTxt.anchor.set(0.5, 0.5);
menuHighScoreTxt.x = 2048 / 2;
menuHighScoreTxt.y = 1100;
self.addChild(menuHighScoreTxt);
// Games played counter
var gamesPlayedTxt = new Text2('Games Played: ' + (storage.totalGamesPlayed || 0), {
size: 50,
fill: 0xCCCCCC
});
gamesPlayedTxt.anchor.set(0.5, 0.5);
gamesPlayedTxt.x = 2048 / 2;
gamesPlayedTxt.y = 1200;
self.addChild(gamesPlayedTxt);
// Shop button
var shopButton = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1.2,
tint: 0xFFD700
});
shopButton.x = 2048 / 2;
shopButton.y = 1600;
self.addChild(shopButton);
var shopTxt = new Text2('SHOP', {
size: 70,
fill: 0x000000
});
shopTxt.anchor.set(0.5, 0.5);
shopTxt.x = 2048 / 2;
shopTxt.y = 1600;
self.addChild(shopTxt);
// Shop button handlers
shopButton.down = function (x, y, obj) {
shop.show();
};
shopTxt.down = function (x, y, obj) {
shop.show();
};
// Start button click handler
startButton.down = function (x, y, obj) {
self.hide();
};
startTxt.down = function (x, y, obj) {
self.hide();
};
self.hide = function () {
tween(self, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
self.visible = false;
gameStarted = true;
LK.playMusic('bgmusic');
}
});
};
// Pulsing animation for start button
tween(startButton, {
scaleX: 4.2,
scaleY: 1.7
}, {
duration: 1000,
repeat: -1,
yoyo: true
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var gameStarted = false;
var startMenu = game.addChild(new StartMenu());
var shop = game.addChild(new Shop());
var character = game.addChild(new Character());
character.x = 2048 / 2;
character.y = 2732 - 200;
character.updateWidth();
var lasers = [];
var laserTimer = 0;
var laserInterval = 20;
// Initialize player upgrade system
var playerUpgrade = new PlayerUpgrade();
playerUpgrade.loadFromStorage();
// Track high score
var currentHighScore = storage.highScore || 0;
var gamesPlayed = storage.totalGamesPlayed || 0;
var fruits = [];
var fruitTypes = ['apple', 'orange', 'banana', 'grape'];
var powerupChance = 0.05; // 5% chance for power-up fruit
var spawnTimer = 0;
var spawnInterval = 90; // frames between fruit spawns
var gameSpeed = 1;
var comboCount = 0;
var comboTimer = 0;
var comboTimeout = 120; // frames before combo resets
var bonusPoints = 0;
var perfectHits = 0;
var timeBonus = 0;
var lastHitTime = 0;
// 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.x = 0;
comboTxt.y = 100;
LK.gui.top.addChild(comboTxt);
// Bonus points display
var bonusTxt = new Text2('Bonus: 0', {
size: 50,
fill: 0x00FF00
});
bonusTxt.anchor.set(0.5, 0);
bonusTxt.x = 0;
bonusTxt.y = 170;
LK.gui.top.addChild(bonusTxt);
// Player level display
var levelTxt = new Text2('Level: ' + playerUpgrade.level, {
size: 45,
fill: 0xFFD700
});
levelTxt.anchor.set(0, 0);
levelTxt.x = 50;
levelTxt.y = 120;
LK.gui.topLeft.addChild(levelTxt);
// Experience bar background
var expBarBg = LK.getAsset('character', {
anchorX: 0,
anchorY: 0,
scaleX: 2,
scaleY: 0.3,
alpha: 0.3
});
expBarBg.x = 50;
expBarBg.y = 180;
LK.gui.topLeft.addChild(expBarBg);
// Experience bar fill
var expBarFill = LK.getAsset('character', {
anchorX: 0,
anchorY: 0,
scaleX: 2 * (playerUpgrade.experience / playerUpgrade.experienceToNext),
scaleY: 0.3,
tint: 0x00FF00
});
expBarFill.x = 50;
expBarFill.y = 180;
LK.gui.topLeft.addChild(expBarFill);
// High score display
var highScoreTxt = new Text2('Best: ' + currentHighScore, {
size: 40,
fill: 0xFFFFFF
});
highScoreTxt.anchor.set(1, 0);
highScoreTxt.x = -50;
highScoreTxt.y = 120;
LK.gui.topRight.addChild(highScoreTxt);
// Back to menu button
var backButton = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 0.8,
tint: 0xFF8800
});
backButton.x = -50;
backButton.y = 180;
LK.gui.topRight.addChild(backButton);
var backTxt = new Text2('MENU', {
size: 35,
fill: 0xFFFFFF
});
backTxt.anchor.set(0.5, 0.5);
backTxt.x = -50;
backTxt.y = 180;
LK.gui.topRight.addChild(backTxt);
// Back button handlers
backButton.down = function (x, y, obj) {
if (gameStarted) {
gameStarted = false;
startMenu.visible = true;
startMenu.alpha = 0;
tween(startMenu, {
alpha: 1
}, {
duration: 300
});
LK.stopMusic();
}
};
backTxt.down = function (x, y, obj) {
if (gameStarted) {
gameStarted = false;
startMenu.visible = true;
startMenu.alpha = 0;
tween(startMenu, {
alpha: 1
}, {
duration: 300
});
LK.stopMusic();
}
};
// Drag controls
var dragNode = null;
function handleMove(x, y, obj) {
if (dragNode) {
// Apply speed upgrade for smoother movement
var speedMultiplier = 1 + (storage.speedUpgrade || 0) * 0.1;
var deltaX = (x - dragNode.x) * speedMultiplier;
var deltaY = (y - dragNode.y) * speedMultiplier;
dragNode.x += deltaX;
dragNode.y += deltaY;
// Keep character within screen bounds
if (dragNode.x < 60) dragNode.x = 60;
if (dragNode.x > 2048 - 60) dragNode.x = 2048 - 60;
if (dragNode.y < 60) dragNode.y = 60;
if (dragNode.y > 2732 - 60) dragNode.y = 2732 - 60;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
if (!gameStarted) {
return;
}
dragNode = character;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
function spawnFruit() {
var randomType;
// Chance for power-up fruit (enhanced by shop upgrades)
var enhancedPowerupChance = powerupChance + (storage.luckUpgrade || 0) * 0.02;
if (Math.random() < enhancedPowerupChance) {
randomType = 'powerup';
} else {
randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
}
var fruit = new Fruit(randomType);
fruit.x = Math.random() * (2048 - 160) + 80;
fruit.y = -80;
fruit.fallSpeed = 3 + gameSpeed * 0.5;
fruit.lastY = fruit.y;
fruit.lastIntersecting = false;
// Add pulsing effect to power-up fruits
if (randomType === 'powerup') {
tween(fruit, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
repeat: -1,
yoyo: true
});
}
fruits.push(fruit);
game.addChild(fruit);
}
function createSmashEffect(x, y) {
// Create multiple small particles for smash effect
for (var i = 0; i < 6; i++) {
var particle = LK.getAsset('apple', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
particle.x = x + (Math.random() - 0.5) * 60;
particle.y = y + (Math.random() - 0.5) * 60;
game.addChild(particle);
// Animate particles
tween(particle, {
x: particle.x + (Math.random() - 0.5) * 200,
y: particle.y + (Math.random() - 0.5) * 200,
alpha: 0,
scaleX: 0,
scaleY: 0
}, {
duration: 800,
onFinish: function onFinish() {
particle.destroy();
}
});
}
}
game.update = function () {
// Don't update game if menu is active
if (!gameStarted) {
return;
}
// Update character width based on laser upgrade
character.updateWidth();
// Spawn lasers if laser upgrade is active
if (storage.laserUpgrade > 0) {
laserTimer++;
if (laserTimer >= laserInterval) {
var laser1 = new Laser();
laser1.x = character.x - 30;
laser1.y = character.y - 60;
laser1.lastY = laser1.y;
laser1.lastIntersecting = false;
lasers.push(laser1);
game.addChild(laser1);
var laser2 = new Laser();
laser2.x = character.x + 30;
laser2.y = character.y - 60;
laser2.lastY = laser2.y;
laser2.lastIntersecting = false;
lasers.push(laser2);
game.addChild(laser2);
LK.getSound('laser').play();
laserTimer = 0;
}
}
// Update lasers
for (var l = lasers.length - 1; l >= 0; l--) {
var laser = lasers[l];
if (laser.lastY >= -50 && laser.y < -50) {
laser.destroy();
lasers.splice(l, 1);
continue;
}
laser.lastY = laser.y;
}
// Check laser-fruit collisions
for (var l = lasers.length - 1; l >= 0; l--) {
var laser = lasers[l];
for (var f = fruits.length - 1; f >= 0; f--) {
var fruit = fruits[f];
if (laser.intersects(fruit)) {
var laserPoints = fruit.points * 2;
LK.setScore(LK.getScore() + laserPoints);
scoreTxt.setText('Score: ' + LK.getScore());
createSmashEffect(fruit.x, fruit.y);
LK.getSound('smash').play();
fruit.destroy();
fruits.splice(f, 1);
laser.destroy();
lasers.splice(l, 1);
break;
}
}
}
// Spawn fruits
spawnTimer++;
if (spawnTimer >= spawnInterval) {
spawnFruit();
spawnTimer = 0;
}
// Update fruits and check collisions
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if fruit went off screen
if (fruit.lastY <= 2732 + 100 && fruit.y > 2732 + 100) {
fruit.destroy();
fruits.splice(i, 1);
continue;
}
// Magnetic attraction effect based on player level and shop upgrades
var magnetBonus = 1 + (storage.magnetUpgrade || 0) * 0.3;
var magnetDistance = 150 * playerUpgrade.magnetPower * magnetBonus;
var distanceToCharacter = Math.sqrt(Math.pow(fruit.x - character.x, 2) + Math.pow(fruit.y - character.y, 2));
if (distanceToCharacter < magnetDistance && distanceToCharacter > 60) {
// Apply magnetic pull
var pullStrength = 0.1 * playerUpgrade.magnetPower;
var directionX = (character.x - fruit.x) / distanceToCharacter;
var directionY = (character.y - fruit.y) / distanceToCharacter;
fruit.x += directionX * pullStrength * 30;
fruit.y += directionY * pullStrength * 30;
}
// Check collision with character
var currentIntersecting = fruit.intersects(character);
if (!fruit.lastIntersecting && currentIntersecting) {
// Fruit smashed!
comboCount++;
comboTimer = 0;
var multiplier = Math.min(comboCount, 5); // Max 5x multiplier
var basePoints = fruit.points;
// Apply shop upgrades
var shopMultiplier = 1 + (storage.multiplierUpgrade || 0) * 0.2;
var points = Math.floor(basePoints * multiplier * playerUpgrade.scoreMultiplier * shopMultiplier);
// Award coins (2 coins per fruit collected)
var coinsEarned = 2;
storage.coins = (storage.coins || 0) + coinsEarned;
// Gain experience from fruit collection
var experienceGained = Math.floor(fruit.points / 5);
playerUpgrade.gainExperience(experienceGained);
// Time bonus - award bonus points for quick successive hits
var currentTime = LK.ticks;
if (currentTime - lastHitTime < 30) {
// Within 0.5 seconds
timeBonus += 5;
points += timeBonus;
} else {
timeBonus = 0;
}
lastHitTime = currentTime;
// Perfect hit bonus - fruit hit near center of screen
var centerX = 2048 / 2;
var distanceFromCenter = Math.abs(fruit.x - centerX);
if (distanceFromCenter < 100) {
perfectHits++;
points += 10; // Perfect hit bonus
bonusPoints += 10;
}
// Power-up fruit special bonus
if (fruit.type === 'powerup') {
points += 25; // Extra bonus for power-up
bonusPoints += 25;
// Flash screen gold for power-up
LK.effects.flashScreen(0xFFD700, 200);
}
// Rare fruit bonus (grapes are worth more)
if (fruit.type === 'grape') {
points += 5;
bonusPoints += 5;
}
LK.setScore(LK.getScore() + points);
scoreTxt.setText('Score: ' + LK.getScore());
// Update level display
levelTxt.setText('Level: ' + playerUpgrade.level);
// Update experience bar
var expProgress = playerUpgrade.experience / playerUpgrade.experienceToNext;
tween(expBarFill, {
scaleX: 2 * expProgress
}, {
duration: 200
});
// Update high score
if (LK.getScore() > currentHighScore) {
currentHighScore = LK.getScore();
storage.highScore = currentHighScore;
highScoreTxt.setText('Best: ' + currentHighScore);
// Flash high score display
tween(highScoreTxt, {
tint: 0xFFD700
}, {
duration: 300,
onFinish: function onFinish() {
tween(highScoreTxt, {
tint: 0xFFFFFF
}, {
duration: 300
});
}
});
}
// Update combo display
if (comboCount > 1) {
comboTxt.setText('COMBO x' + multiplier + '!');
tween(comboTxt, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
onFinish: function onFinish() {
tween(comboTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
}
// Update bonus display
bonusTxt.setText('Bonus: ' + bonusPoints);
// Create floating point text for visual feedback
var pointText = new Text2('+' + points, {
size: 40,
fill: 0xFFFFFF
});
pointText.anchor.set(0.5, 0.5);
pointText.x = fruit.x;
pointText.y = fruit.y - 50;
game.addChild(pointText);
// Animate point text
tween(pointText, {
y: pointText.y - 100,
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
pointText.destroy();
}
});
// Create smash effect
createSmashEffect(fruit.x, fruit.y);
// Play smash sound
LK.getSound('smash').play();
// Visual feedback - flash screen and scale character
LK.effects.flashScreen(0xFFFFFF, 100);
tween(character, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 150,
onFinish: function onFinish() {
tween(character, {
scaleX: 1,
scaleY: 1
}, {
duration: 150
});
}
});
// Score milestone bonuses
var currentScore = LK.getScore();
if (currentScore >= 100 && currentScore < 105) {
bonusPoints += 50;
LK.setScore(currentScore + 50);
scoreTxt.setText('Score: ' + LK.getScore());
}
if (currentScore >= 250 && currentScore < 255) {
bonusPoints += 100;
LK.setScore(currentScore + 100);
scoreTxt.setText('Score: ' + LK.getScore());
}
// Perfect hit streak bonus
if (perfectHits >= 5 && perfectHits % 5 === 0) {
var streakBonus = perfectHits * 2;
bonusPoints += streakBonus;
LK.setScore(currentScore + streakBonus);
scoreTxt.setText('Score: ' + LK.getScore());
}
// Check for win condition
if (LK.getScore() >= 25000) {
// Save final game statistics
storage.totalGamesPlayed = gamesPlayed + 1;
storage.playerLevel = playerUpgrade.level;
storage.playerExperience = playerUpgrade.experience;
LK.showYouWin();
return;
}
fruit.destroy();
fruits.splice(i, 1);
continue;
}
// Update last known states
fruit.lastY = fruit.y;
fruit.lastIntersecting = currentIntersecting;
}
// Manage combo timer
comboTimer++;
if (comboTimer >= comboTimeout && comboCount > 0) {
comboCount = 0;
comboTxt.setText('');
}
// Increase game speed based on score
gameSpeed = 1 + LK.getScore() / 200;
// Decrease spawn interval as speed increases
spawnInterval = Math.max(30, 90 - LK.getScore() / 10);
// Add more fruit types as score increases
if (LK.getScore() >= 100 && fruitTypes.length < 4) {
// All fruit types are already available from start
}
}; ===================================================================
--- original.js
+++ change.js
@@ -757,10 +757,10 @@
var basePoints = fruit.points;
// Apply shop upgrades
var shopMultiplier = 1 + (storage.multiplierUpgrade || 0) * 0.2;
var points = Math.floor(basePoints * multiplier * playerUpgrade.scoreMultiplier * shopMultiplier);
- // Award coins (1 coin per 10 points)
- var coinsEarned = Math.floor(points / 10);
+ // Award coins (2 coins per fruit collected)
+ var coinsEarned = 2;
storage.coins = (storage.coins || 0) + coinsEarned;
// Gain experience from fruit collection
var experienceGained = Math.floor(fruit.points / 5);
playerUpgrade.gainExperience(experienceGained);