/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Basket = Container.expand(function () { var self = Container.call(this); var basketGraphics = self.attachAsset('basket', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 1.5 }); self.width = basketGraphics.width * 2; self.height = basketGraphics.height * 1.5; self.down = function (x, y, obj) { self.dragging = true; }; self.up = function (x, y, obj) { self.dragging = false; }; return self; }); var Fruit = Container.expand(function (type) { var self = Container.call(this); self.type = type || 'apple'; self.speed = 3 + Math.random() * 2; self.value = 10; if (self.type === 'banana') { self.value = 15; self.speed += 1; } else if (self.type === 'orange') { self.value = 20; self.speed += 2; } else if (self.type === 'goldenApple') { self.value = 50; self.speed += 3; } else if (self.type === 'rottenFruit') { self.value = -20; self.speed += 1; } else if (self.type === 'bomb') { self.value = -1; // Special value for bomb self.speed += 2; } var fruitGraphics = self.attachAsset(self.type, { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.y += self.speed * gameSpeed; // Add some swinging motion for realistic falling self.x += Math.sin(LK.ticks / 20 + self.y / 100) * 1; // Add slight rotation fruitGraphics.rotation += 0.01; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ var basket; var fruits = []; var score = 0; var lives = 3; var gameSpeed = 1; var fruitTypes = ['apple', 'banana', 'orange', 'rottenFruit', 'goldenApple', 'bomb']; var fruitSpawnRate = 60; // Frames between fruit spawns var lastFruitSpawn = 0; var speedIncreaseInterval = 1000; // Frames between speed increases var isPaused = false; var isGameOver = false; var dragNode = null; // UI elements var scoreTxt, livesTxt, gameSpeedTxt; // Initialize game function initGame() { // Create basket basket = new Basket(); basket.x = 2048 / 2; basket.y = 2732 - 200; game.addChild(basket); // Initialize score display scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); LK.gui.topRight.addChild(scoreTxt); // Initialize lives display livesTxt = new Text2('Lives: ' + lives, { size: 80, fill: 0xFFFFFF }); livesTxt.anchor.set(0, 0); LK.gui.top.addChild(livesTxt); // Initialize game speed display gameSpeedTxt = new Text2('Speed: 1.0x', { size: 60, fill: 0xFFFFFF }); gameSpeedTxt.anchor.set(1, 0); LK.gui.bottomRight.addChild(gameSpeedTxt); // Play background music LK.playMusic('gameMusic', { fade: { start: 0, end: 0.4, duration: 1000 } }); // Initialize stored high score if needed if (!storage.highScore) { storage.highScore = 0; } } // Spawn a new fruit function spawnFruit() { var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)]; // Adjust probabilities for special items if (randomType === 'goldenApple' && Math.random() < 0.8) { randomType = fruitTypes[Math.floor(Math.random() * 3)]; // More likely to be a common fruit } if (randomType === 'bomb' && Math.random() < 0.7) { randomType = fruitTypes[Math.floor(Math.random() * 3)]; // More likely to be a common fruit } var fruit = new Fruit(randomType); fruit.x = Math.random() * (2048 - 100) + 50; // Random position fruit.y = -50; // Start above the screen game.addChild(fruit); fruits.push(fruit); } // Update score display function updateScore(points) { score += points; LK.setScore(score); scoreTxt.setText('Score: ' + score); // Check if we have a new high score if (score > storage.highScore) { storage.highScore = score; } } // Handle fruit catching and collisions function checkCollisions() { for (var i = fruits.length - 1; i >= 0; i--) { var fruit = fruits[i]; // Check if fruit is below the screen (missed) if (fruit.y > 2732 + 50) { fruit.destroy(); fruits.splice(i, 1); continue; } // Check collision with basket if (fruit.intersects(basket)) { // Handle different fruit types if (fruit.type === 'bomb') { // Bomb - lose a life lives--; livesTxt.setText('Lives: ' + lives); LK.getSound('explosion').play(); LK.effects.flashScreen(0xFF0000, 500); if (lives <= 0) { gameOver(); } } else if (fruit.type === 'goldenApple') { // Golden apple - bonus points and speed boost updateScore(fruit.value); gameSpeed += 0.1; gameSpeedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x'); LK.getSound('powerup').play(); } else if (fruit.type === 'rottenFruit') { // Rotten fruit - lose points updateScore(fruit.value); LK.getSound('loseLife').play(); } else { // Regular fruit - add points updateScore(fruit.value); LK.getSound('catch').play(); } // Remove caught fruit fruit.destroy(); fruits.splice(i, 1); // Visual feedback if (fruit.type !== 'bomb') { LK.effects.flashObject(basket, 0x00FF00, 200); } } } } // Game over function function gameOver() { isGameOver = true; LK.showGameOver(); } // Handle dragging the basket function handleMove(x, y, obj) { if (dragNode === basket) { basket.x = x; // Keep basket within screen bounds if (basket.x < basket.width / 2) { basket.x = basket.width / 2; } else if (basket.x > 2048 - basket.width / 2) { basket.x = 2048 - basket.width / 2; } } } // Set up event handlers game.down = function (x, y, obj) { dragNode = basket; handleMove(x, y, obj); }; game.up = function (x, y, obj) { dragNode = null; }; game.move = handleMove; // Main game update function game.update = function () { if (isGameOver) return; // Spawn new fruits if (LK.ticks - lastFruitSpawn > fruitSpawnRate) { spawnFruit(); lastFruitSpawn = LK.ticks; // Gradually decrease spawn rate for increasing difficulty if (fruitSpawnRate > 20) { fruitSpawnRate -= 0.1; } } // Increase game speed over time if (LK.ticks % speedIncreaseInterval === 0) { gameSpeed += 0.005; gameSpeedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x'); } // Update all fruits for (var i = 0; i < fruits.length; i++) { fruits[i].update(); } // Check for catches and misses checkCollisions(); }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,252 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var Basket = Container.expand(function () {
+ var self = Container.call(this);
+ var basketGraphics = self.attachAsset('basket', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 1.5
+ });
+ self.width = basketGraphics.width * 2;
+ self.height = basketGraphics.height * 1.5;
+ self.down = function (x, y, obj) {
+ self.dragging = true;
+ };
+ self.up = function (x, y, obj) {
+ self.dragging = false;
+ };
+ return self;
+});
+var Fruit = Container.expand(function (type) {
+ var self = Container.call(this);
+ self.type = type || 'apple';
+ self.speed = 3 + Math.random() * 2;
+ self.value = 10;
+ if (self.type === 'banana') {
+ self.value = 15;
+ self.speed += 1;
+ } else if (self.type === 'orange') {
+ self.value = 20;
+ self.speed += 2;
+ } else if (self.type === 'goldenApple') {
+ self.value = 50;
+ self.speed += 3;
+ } else if (self.type === 'rottenFruit') {
+ self.value = -20;
+ self.speed += 1;
+ } else if (self.type === 'bomb') {
+ self.value = -1; // Special value for bomb
+ self.speed += 2;
+ }
+ var fruitGraphics = self.attachAsset(self.type, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ self.y += self.speed * gameSpeed;
+ // Add some swinging motion for realistic falling
+ self.x += Math.sin(LK.ticks / 20 + self.y / 100) * 1;
+ // Add slight rotation
+ fruitGraphics.rotation += 0.01;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB // Sky blue background
+});
+
+/****
+* Game Code
+****/
+var basket;
+var fruits = [];
+var score = 0;
+var lives = 3;
+var gameSpeed = 1;
+var fruitTypes = ['apple', 'banana', 'orange', 'rottenFruit', 'goldenApple', 'bomb'];
+var fruitSpawnRate = 60; // Frames between fruit spawns
+var lastFruitSpawn = 0;
+var speedIncreaseInterval = 1000; // Frames between speed increases
+var isPaused = false;
+var isGameOver = false;
+var dragNode = null;
+// UI elements
+var scoreTxt, livesTxt, gameSpeedTxt;
+// Initialize game
+function initGame() {
+ // Create basket
+ basket = new Basket();
+ basket.x = 2048 / 2;
+ basket.y = 2732 - 200;
+ game.addChild(basket);
+ // Initialize score display
+ scoreTxt = new Text2('Score: 0', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ scoreTxt.anchor.set(0, 0);
+ LK.gui.topRight.addChild(scoreTxt);
+ // Initialize lives display
+ livesTxt = new Text2('Lives: ' + lives, {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ livesTxt.anchor.set(0, 0);
+ LK.gui.top.addChild(livesTxt);
+ // Initialize game speed display
+ gameSpeedTxt = new Text2('Speed: 1.0x', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ gameSpeedTxt.anchor.set(1, 0);
+ LK.gui.bottomRight.addChild(gameSpeedTxt);
+ // Play background music
+ LK.playMusic('gameMusic', {
+ fade: {
+ start: 0,
+ end: 0.4,
+ duration: 1000
+ }
+ });
+ // Initialize stored high score if needed
+ if (!storage.highScore) {
+ storage.highScore = 0;
+ }
+}
+// Spawn a new fruit
+function spawnFruit() {
+ var randomType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)];
+ // Adjust probabilities for special items
+ if (randomType === 'goldenApple' && Math.random() < 0.8) {
+ randomType = fruitTypes[Math.floor(Math.random() * 3)]; // More likely to be a common fruit
+ }
+ if (randomType === 'bomb' && Math.random() < 0.7) {
+ randomType = fruitTypes[Math.floor(Math.random() * 3)]; // More likely to be a common fruit
+ }
+ var fruit = new Fruit(randomType);
+ fruit.x = Math.random() * (2048 - 100) + 50; // Random position
+ fruit.y = -50; // Start above the screen
+ game.addChild(fruit);
+ fruits.push(fruit);
+}
+// Update score display
+function updateScore(points) {
+ score += points;
+ LK.setScore(score);
+ scoreTxt.setText('Score: ' + score);
+ // Check if we have a new high score
+ if (score > storage.highScore) {
+ storage.highScore = score;
+ }
+}
+// Handle fruit catching and collisions
+function checkCollisions() {
+ for (var i = fruits.length - 1; i >= 0; i--) {
+ var fruit = fruits[i];
+ // Check if fruit is below the screen (missed)
+ if (fruit.y > 2732 + 50) {
+ fruit.destroy();
+ fruits.splice(i, 1);
+ continue;
+ }
+ // Check collision with basket
+ if (fruit.intersects(basket)) {
+ // Handle different fruit types
+ if (fruit.type === 'bomb') {
+ // Bomb - lose a life
+ lives--;
+ livesTxt.setText('Lives: ' + lives);
+ LK.getSound('explosion').play();
+ LK.effects.flashScreen(0xFF0000, 500);
+ if (lives <= 0) {
+ gameOver();
+ }
+ } else if (fruit.type === 'goldenApple') {
+ // Golden apple - bonus points and speed boost
+ updateScore(fruit.value);
+ gameSpeed += 0.1;
+ gameSpeedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x');
+ LK.getSound('powerup').play();
+ } else if (fruit.type === 'rottenFruit') {
+ // Rotten fruit - lose points
+ updateScore(fruit.value);
+ LK.getSound('loseLife').play();
+ } else {
+ // Regular fruit - add points
+ updateScore(fruit.value);
+ LK.getSound('catch').play();
+ }
+ // Remove caught fruit
+ fruit.destroy();
+ fruits.splice(i, 1);
+ // Visual feedback
+ if (fruit.type !== 'bomb') {
+ LK.effects.flashObject(basket, 0x00FF00, 200);
+ }
+ }
+ }
+}
+// Game over function
+function gameOver() {
+ isGameOver = true;
+ LK.showGameOver();
+}
+// Handle dragging the basket
+function handleMove(x, y, obj) {
+ if (dragNode === basket) {
+ basket.x = x;
+ // Keep basket within screen bounds
+ if (basket.x < basket.width / 2) {
+ basket.x = basket.width / 2;
+ } else if (basket.x > 2048 - basket.width / 2) {
+ basket.x = 2048 - basket.width / 2;
+ }
+ }
+}
+// Set up event handlers
+game.down = function (x, y, obj) {
+ dragNode = basket;
+ handleMove(x, y, obj);
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+game.move = handleMove;
+// Main game update function
+game.update = function () {
+ if (isGameOver) return;
+ // Spawn new fruits
+ if (LK.ticks - lastFruitSpawn > fruitSpawnRate) {
+ spawnFruit();
+ lastFruitSpawn = LK.ticks;
+ // Gradually decrease spawn rate for increasing difficulty
+ if (fruitSpawnRate > 20) {
+ fruitSpawnRate -= 0.1;
+ }
+ }
+ // Increase game speed over time
+ if (LK.ticks % speedIncreaseInterval === 0) {
+ gameSpeed += 0.005;
+ gameSpeedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x');
+ }
+ // Update all fruits
+ for (var i = 0; i < fruits.length; i++) {
+ fruits[i].update();
+ }
+ // Check for catches and misses
+ checkCollisions();
+};
+// Initialize the game
+initGame();
\ No newline at end of file
a pixel art of a basket. In-Game asset. 2d. High contrast. No shadows
pixel art of a rotten apple. In-Game asset. 2d. High contrast. No shadows
pixel art of an apple. In-Game asset. 2d. High contrast. No shadows
pixel art of a apple but golden. In-Game asset. 2d. High contrast. No shadows
pixel art of a lemon. In-Game asset. 2d. High contrast. No shadows
pixel art of a orange. In-Game asset. 2d. High contrast. No shadows
a pixel art of a banana. In-Game asset. 2d. High contrast. No shadows
a pixel art of a bomb. In-Game asset. 2d. High contrast. No shadows