/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Basket = Container.expand(function () { var self = Container.call(this); var basketGraphics = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Fruit = Container.expand(function () { var self = Container.call(this); self.fruitType = 'apple'; self.fallSpeed = 3; self.points = 10; self.init = function (type) { self.fruitType = type; // Set properties based on fruit type switch (type) { case 'apple': self.fruitGraphics = self.attachAsset('apple', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.points = 10; break; case 'orange': self.fruitGraphics = self.attachAsset('orange', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.points = 15; break; case 'banana': self.fruitGraphics = self.attachAsset('banana', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.points = 20; break; case 'cherry': self.fruitGraphics = self.attachAsset('cherry', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.points = 25; break; } self.fallSpeed = Math.random() * 2 + 2; // Random speed between 2-4 }; self.update = function () { self.y += self.fallSpeed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Set cat_damage as background var background = game.addChild(LK.getAsset('Cat_damage', { anchorX: 0, anchorY: 0, x: 0, y: 0, scaleX: 20.48, scaleY: 27.32 })); // Game variables var basket; var fruits = []; var missedFruits = 0; var maxMissedFruits = 5; var fruitSpawnTimer = 0; var fruitSpawnRate = 90; // Spawn every 90 ticks initially var gameSpeed = 1; var level = 1; // Fruit types for random selection var fruitTypes = ['apple', 'orange', 'banana', 'cherry']; // Pie system variables var fruitInventory = { apple: 0, orange: 0, banana: 0, cherry: 0 }; // Pie recipes - what fruits needed for each pie var pieRecipes = { applePie: { apple: 5, cost: { apple: 5 }, points: 100, color: 0x00FF00 }, cherryPie: { cherry: 3, cost: { cherry: 3 }, points: 150, color: 0xFF0000 }, fruitSalad: { apple: 2, orange: 2, banana: 1, cost: { apple: 2, orange: 2, banana: 1 }, points: 200, color: 0xFFFF00 }, mixedPie: { apple: 1, orange: 1, banana: 1, cherry: 1, cost: { apple: 1, orange: 1, banana: 1, cherry: 1 }, points: 250, color: 0xFF00FF } }; var completedPies = 0; // Create ground var ground = game.addChild(LK.getAsset('ground', { anchorX: 0, anchorY: 1, x: 0, y: 2732, scaleY: 0.3 })); // Create and position basket basket = game.addChild(new Basket()); basket.x = 1024; // Center horizontally basket.y = 2500; // Near bottom but above ground basket.scaleX = 1.5; // Make basket larger basket.scaleY = 1.5; // Make basket larger // Create UI elements var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); LK.gui.topRight.addChild(scoreTxt); var livesTxt = new Text2('Lives: ' + (maxMissedFruits - missedFruits), { size: 80, fill: 0xFFFFFF }); livesTxt.anchor.set(1, 0); LK.gui.topLeft.addChild(livesTxt); var levelTxt = new Text2('Level: ' + level, { size: 60, fill: 0xFFFFFF }); levelTxt.anchor.set(0.5, 0); LK.gui.top.addChild(levelTxt); // Fruit inventory display var inventoryTxt = new Text2('Fruits: A:0 O:0 B:0 C:0', { size: 50, fill: 0xFFFFFF }); inventoryTxt.anchor.set(0, 1); LK.gui.bottomLeft.addChild(inventoryTxt); // Pie counter display var piesTxt = new Text2('Pies Made: 0', { size: 50, fill: 0xFFFF00 }); piesTxt.anchor.set(1, 1); LK.gui.bottomRight.addChild(piesTxt); // Recipe notification area var recipeTxt = new Text2('', { size: 40, fill: 0x00FF00 }); recipeTxt.anchor.set(0.5, 0); recipeTxt.y = 150; LK.gui.top.addChild(recipeTxt); // Touch controls for basket movement var isDragging = false; game.down = function (x, y, obj) { isDragging = true; basket.x = x; }; game.move = function (x, y, obj) { if (isDragging) { basket.x = Math.max(100, Math.min(1948, x)); // Keep basket within screen bounds } }; game.up = function (x, y, obj) { isDragging = false; }; // Spawn fruit function function spawnFruit() { var fruit = new Fruit(); var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)]; fruit.init(randomType); fruit.x = Math.random() * 1848 + 100; // Random x position within screen bounds fruit.y = -50; // Start above screen fruits.push(fruit); game.addChild(fruit); } // Update fruit inventory display function updateInventoryDisplay() { inventoryTxt.setText('Fruits: A:' + fruitInventory.apple + ' O:' + fruitInventory.orange + ' B:' + fruitInventory.banana + ' C:' + fruitInventory.cherry); } // Check if we can make any pies function checkPieRecipes() { for (var pieType in pieRecipes) { var recipe = pieRecipes[pieType]; var canMake = true; // Check if we have enough of each required fruit for (var fruitType in recipe.cost) { if (fruitInventory[fruitType] < recipe.cost[fruitType]) { canMake = false; break; } } if (canMake) { makePie(pieType, recipe); return; // Only make one pie at a time } } } // Make a pie and consume fruits function makePie(pieType, recipe) { // Consume the required fruits for (var fruitType in recipe.cost) { fruitInventory[fruitType] -= recipe.cost[fruitType]; } // Add points and update displays LK.setScore(LK.getScore() + recipe.points); scoreTxt.setText('Score: ' + LK.getScore()); completedPies++; piesTxt.setText('Pies Made: ' + completedPies); // Play cake sound when pie is made LK.getSound('Cake_point').play(); // Create and animate cake icon var cakeIcon = game.addChild(LK.getAsset('Cake_icon', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, scaleX: 0, scaleY: 0, alpha: 0 })); // Animate cake icon appearing tween(cakeIcon, { scaleX: 1.5, scaleY: 1.5, alpha: 1 }, { duration: 500, easing: tween.bounceOut, onFinish: function onFinish() { // Hold for a moment then fade out LK.setTimeout(function () { tween(cakeIcon, { scaleX: 0.5, scaleY: 0.5, alpha: 0 }, { duration: 800, easing: tween.easeIn, onFinish: function onFinish() { cakeIcon.destroy(); } }); }, 1000); } }); // Show pie creation notification var pieNames = { applePie: 'Apple Pie', cherryPie: 'Cherry Pie', fruitSalad: 'Fruit Salad', mixedPie: 'Mixed Pie' }; recipeTxt.setText(pieNames[pieType] + ' Made! +' + recipe.points + ' pts'); recipeTxt.tint = recipe.color; // Flash screen with pie color LK.effects.flashScreen(recipe.color, 800); // Clear notification after 2 seconds LK.setTimeout(function () { recipeTxt.setText(''); }, 2000); updateInventoryDisplay(); } // Update difficulty based on score function updateDifficulty() { var newLevel = Math.floor(LK.getScore() / 200) + 1; if (newLevel > level) { level = newLevel; levelTxt.setText('Level: ' + level); // Increase difficulty fruitSpawnRate = Math.max(30, fruitSpawnRate - 10); // Faster spawning, minimum 30 ticks gameSpeed = Math.min(2, 1 + (level - 1) * 0.2); // Increase game speed } } // Main game update loop game.update = function () { // Spawn fruits fruitSpawnTimer++; if (fruitSpawnTimer >= fruitSpawnRate) { spawnFruit(); fruitSpawnTimer = 0; } // Update fruits and check collisions for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; // Check if fruit was caught by basket if (fruit.intersects(basket)) { // Fruit caught! LK.setScore(LK.getScore() + fruit.points); scoreTxt.setText('Score: ' + LK.getScore()); // Add fruit to inventory fruitInventory[fruit.fruitType]++; updateInventoryDisplay(); // Check if we can make any pies checkPieRecipes(); // Flash basket green briefly LK.effects.flashObject(basket, 0x00FF00, 300); LK.getSound('catch').play(); fruit.destroy(); fruits.splice(i, 1); continue; } // Check if fruit hit the ground if (fruit.y > 2550) { // Ground level minus some buffer // Fruit missed! missedFruits++; livesTxt.setText('Lives: ' + (maxMissedFruits - missedFruits)); // Flash screen red briefly LK.effects.flashScreen(0xFF0000, 500); LK.getSound('miss').play(); fruit.destroy(); fruits.splice(i, 1); // Check game over condition if (missedFruits >= maxMissedFruits) { LK.showGameOver(); return; } continue; } // Remove fruits that are way off screen if (fruit.y > 2800) { fruit.destroy(); fruits.splice(i, 1); } } // Update difficulty updateDifficulty(); // Check win condition - make 10 pies or reach 2000 points if (completedPies >= 10 || LK.getScore() >= 2000) { LK.showYouWin(); } }; // Start background music LK.playMusic('bgmusic');
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Basket = Container.expand(function () {
var self = Container.call(this);
var basketGraphics = self.attachAsset('basket', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Fruit = Container.expand(function () {
var self = Container.call(this);
self.fruitType = 'apple';
self.fallSpeed = 3;
self.points = 10;
self.init = function (type) {
self.fruitType = type;
// Set properties based on fruit type
switch (type) {
case 'apple':
self.fruitGraphics = self.attachAsset('apple', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.points = 10;
break;
case 'orange':
self.fruitGraphics = self.attachAsset('orange', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.points = 15;
break;
case 'banana':
self.fruitGraphics = self.attachAsset('banana', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.points = 20;
break;
case 'cherry':
self.fruitGraphics = self.attachAsset('cherry', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
});
self.points = 25;
break;
}
self.fallSpeed = Math.random() * 2 + 2; // Random speed between 2-4
};
self.update = function () {
self.y += self.fallSpeed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Set cat_damage as background
var background = game.addChild(LK.getAsset('Cat_damage', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
scaleX: 20.48,
scaleY: 27.32
}));
// Game variables
var basket;
var fruits = [];
var missedFruits = 0;
var maxMissedFruits = 5;
var fruitSpawnTimer = 0;
var fruitSpawnRate = 90; // Spawn every 90 ticks initially
var gameSpeed = 1;
var level = 1;
// Fruit types for random selection
var fruitTypes = ['apple', 'orange', 'banana', 'cherry'];
// Pie system variables
var fruitInventory = {
apple: 0,
orange: 0,
banana: 0,
cherry: 0
};
// Pie recipes - what fruits needed for each pie
var pieRecipes = {
applePie: {
apple: 5,
cost: {
apple: 5
},
points: 100,
color: 0x00FF00
},
cherryPie: {
cherry: 3,
cost: {
cherry: 3
},
points: 150,
color: 0xFF0000
},
fruitSalad: {
apple: 2,
orange: 2,
banana: 1,
cost: {
apple: 2,
orange: 2,
banana: 1
},
points: 200,
color: 0xFFFF00
},
mixedPie: {
apple: 1,
orange: 1,
banana: 1,
cherry: 1,
cost: {
apple: 1,
orange: 1,
banana: 1,
cherry: 1
},
points: 250,
color: 0xFF00FF
}
};
var completedPies = 0;
// Create ground
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 1,
x: 0,
y: 2732,
scaleY: 0.3
}));
// Create and position basket
basket = game.addChild(new Basket());
basket.x = 1024; // Center horizontally
basket.y = 2500; // Near bottom but above ground
basket.scaleX = 1.5; // Make basket larger
basket.scaleY = 1.5; // Make basket larger
// Create UI elements
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreTxt);
var livesTxt = new Text2('Lives: ' + (maxMissedFruits - missedFruits), {
size: 80,
fill: 0xFFFFFF
});
livesTxt.anchor.set(1, 0);
LK.gui.topLeft.addChild(livesTxt);
var levelTxt = new Text2('Level: ' + level, {
size: 60,
fill: 0xFFFFFF
});
levelTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(levelTxt);
// Fruit inventory display
var inventoryTxt = new Text2('Fruits: A:0 O:0 B:0 C:0', {
size: 50,
fill: 0xFFFFFF
});
inventoryTxt.anchor.set(0, 1);
LK.gui.bottomLeft.addChild(inventoryTxt);
// Pie counter display
var piesTxt = new Text2('Pies Made: 0', {
size: 50,
fill: 0xFFFF00
});
piesTxt.anchor.set(1, 1);
LK.gui.bottomRight.addChild(piesTxt);
// Recipe notification area
var recipeTxt = new Text2('', {
size: 40,
fill: 0x00FF00
});
recipeTxt.anchor.set(0.5, 0);
recipeTxt.y = 150;
LK.gui.top.addChild(recipeTxt);
// Touch controls for basket movement
var isDragging = false;
game.down = function (x, y, obj) {
isDragging = true;
basket.x = x;
};
game.move = function (x, y, obj) {
if (isDragging) {
basket.x = Math.max(100, Math.min(1948, x)); // Keep basket within screen bounds
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
// Spawn fruit function
function spawnFruit() {
var fruit = new Fruit();
var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
fruit.init(randomType);
fruit.x = Math.random() * 1848 + 100; // Random x position within screen bounds
fruit.y = -50; // Start above screen
fruits.push(fruit);
game.addChild(fruit);
}
// Update fruit inventory display
function updateInventoryDisplay() {
inventoryTxt.setText('Fruits: A:' + fruitInventory.apple + ' O:' + fruitInventory.orange + ' B:' + fruitInventory.banana + ' C:' + fruitInventory.cherry);
}
// Check if we can make any pies
function checkPieRecipes() {
for (var pieType in pieRecipes) {
var recipe = pieRecipes[pieType];
var canMake = true;
// Check if we have enough of each required fruit
for (var fruitType in recipe.cost) {
if (fruitInventory[fruitType] < recipe.cost[fruitType]) {
canMake = false;
break;
}
}
if (canMake) {
makePie(pieType, recipe);
return; // Only make one pie at a time
}
}
}
// Make a pie and consume fruits
function makePie(pieType, recipe) {
// Consume the required fruits
for (var fruitType in recipe.cost) {
fruitInventory[fruitType] -= recipe.cost[fruitType];
}
// Add points and update displays
LK.setScore(LK.getScore() + recipe.points);
scoreTxt.setText('Score: ' + LK.getScore());
completedPies++;
piesTxt.setText('Pies Made: ' + completedPies);
// Play cake sound when pie is made
LK.getSound('Cake_point').play();
// Create and animate cake icon
var cakeIcon = game.addChild(LK.getAsset('Cake_icon', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
scaleX: 0,
scaleY: 0,
alpha: 0
}));
// Animate cake icon appearing
tween(cakeIcon, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 1
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
// Hold for a moment then fade out
LK.setTimeout(function () {
tween(cakeIcon, {
scaleX: 0.5,
scaleY: 0.5,
alpha: 0
}, {
duration: 800,
easing: tween.easeIn,
onFinish: function onFinish() {
cakeIcon.destroy();
}
});
}, 1000);
}
});
// Show pie creation notification
var pieNames = {
applePie: 'Apple Pie',
cherryPie: 'Cherry Pie',
fruitSalad: 'Fruit Salad',
mixedPie: 'Mixed Pie'
};
recipeTxt.setText(pieNames[pieType] + ' Made! +' + recipe.points + ' pts');
recipeTxt.tint = recipe.color;
// Flash screen with pie color
LK.effects.flashScreen(recipe.color, 800);
// Clear notification after 2 seconds
LK.setTimeout(function () {
recipeTxt.setText('');
}, 2000);
updateInventoryDisplay();
}
// Update difficulty based on score
function updateDifficulty() {
var newLevel = Math.floor(LK.getScore() / 200) + 1;
if (newLevel > level) {
level = newLevel;
levelTxt.setText('Level: ' + level);
// Increase difficulty
fruitSpawnRate = Math.max(30, fruitSpawnRate - 10); // Faster spawning, minimum 30 ticks
gameSpeed = Math.min(2, 1 + (level - 1) * 0.2); // Increase game speed
}
}
// Main game update loop
game.update = function () {
// Spawn fruits
fruitSpawnTimer++;
if (fruitSpawnTimer >= fruitSpawnRate) {
spawnFruit();
fruitSpawnTimer = 0;
}
// Update fruits and check collisions
for (var i = fruits.length - 1; i >= 0; i--) {
var fruit = fruits[i];
// Check if fruit was caught by basket
if (fruit.intersects(basket)) {
// Fruit caught!
LK.setScore(LK.getScore() + fruit.points);
scoreTxt.setText('Score: ' + LK.getScore());
// Add fruit to inventory
fruitInventory[fruit.fruitType]++;
updateInventoryDisplay();
// Check if we can make any pies
checkPieRecipes();
// Flash basket green briefly
LK.effects.flashObject(basket, 0x00FF00, 300);
LK.getSound('catch').play();
fruit.destroy();
fruits.splice(i, 1);
continue;
}
// Check if fruit hit the ground
if (fruit.y > 2550) {
// Ground level minus some buffer
// Fruit missed!
missedFruits++;
livesTxt.setText('Lives: ' + (maxMissedFruits - missedFruits));
// Flash screen red briefly
LK.effects.flashScreen(0xFF0000, 500);
LK.getSound('miss').play();
fruit.destroy();
fruits.splice(i, 1);
// Check game over condition
if (missedFruits >= maxMissedFruits) {
LK.showGameOver();
return;
}
continue;
}
// Remove fruits that are way off screen
if (fruit.y > 2800) {
fruit.destroy();
fruits.splice(i, 1);
}
}
// Update difficulty
updateDifficulty();
// Check win condition - make 10 pies or reach 2000 points
if (completedPies >= 10 || LK.getScore() >= 2000) {
LK.showYouWin();
}
};
// Start background music
LK.playMusic('bgmusic');
Banana cute. In-Game asset. 2d. High contrast. No shadows
Manzana cute. In-Game asset. 2d. High contrast. No shadows
Una cereza roja,la fruta que va en la punta del pastel. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Naranja cute. In-Game asset. 2d. High contrast. No shadows
Pastel :D. In-Game asset. 2d. High contrast. No shadows
Suelo con tierra y cesped. In-Game asset. 2d. High contrast. No shadows
Fondo de pastelería. In-Game asset. 2d. High contrast. No shadows
Chef con una cesta en la mano. In-Game asset. 2d. High contrast. No shadows