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");
/****
* Classes
****/
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.attachAsset('character', {
anchorX: 0.5,
anchorY: 0.5
});
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;
}
self.update = function () {
self.y += self.fallSpeed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var character = game.addChild(new Character());
character.x = 2048 / 2;
character.y = 2732 - 200;
var fruits = [];
var fruitTypes = ['apple', 'orange', 'banana', 'grape'];
var spawnTimer = 0;
var spawnInterval = 90; // frames between fruit spawns
var gameSpeed = 1;
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Drag controls
var dragNode = null;
function handleMove(x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
// 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) {
dragNode = character;
handleMove(x, y, obj);
};
game.up = function (x, y, obj) {
dragNode = null;
};
function spawnFruit() {
var 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;
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 () {
// 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;
}
// Check collision with character
var currentIntersecting = fruit.intersects(character);
if (!fruit.lastIntersecting && currentIntersecting) {
// Fruit smashed!
LK.setScore(LK.getScore() + fruit.points);
scoreTxt.setText('Score: ' + LK.getScore());
// Create smash effect
createSmashEffect(fruit.x, fruit.y);
// Play smash sound
LK.getSound('smash').play();
// Check for win condition
if (LK.getScore() >= 500) {
LK.showYouWin();
return;
}
fruit.destroy();
fruits.splice(i, 1);
continue;
}
// Update last known states
fruit.lastY = fruit.y;
fruit.lastIntersecting = currentIntersecting;
}
// 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
}
};
// Start background music
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,180 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Character = Container.expand(function () {
+ var self = Container.call(this);
+ var characterGraphics = self.attachAsset('character', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ 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;
+ }
+ self.update = function () {
+ self.y += self.fallSpeed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+var character = game.addChild(new Character());
+character.x = 2048 / 2;
+character.y = 2732 - 200;
+var fruits = [];
+var fruitTypes = ['apple', 'orange', 'banana', 'grape'];
+var spawnTimer = 0;
+var spawnInterval = 90; // frames between fruit spawns
+var gameSpeed = 1;
+// Score display
+var scoreTxt = new Text2('Score: 0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Drag controls
+var dragNode = null;
+function handleMove(x, y, obj) {
+ if (dragNode) {
+ dragNode.x = x;
+ dragNode.y = y;
+ // 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) {
+ dragNode = character;
+ handleMove(x, y, obj);
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+function spawnFruit() {
+ var 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;
+ 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 () {
+ // 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;
+ }
+ // Check collision with character
+ var currentIntersecting = fruit.intersects(character);
+ if (!fruit.lastIntersecting && currentIntersecting) {
+ // Fruit smashed!
+ LK.setScore(LK.getScore() + fruit.points);
+ scoreTxt.setText('Score: ' + LK.getScore());
+ // Create smash effect
+ createSmashEffect(fruit.x, fruit.y);
+ // Play smash sound
+ LK.getSound('smash').play();
+ // Check for win condition
+ if (LK.getScore() >= 500) {
+ LK.showYouWin();
+ return;
+ }
+ fruit.destroy();
+ fruits.splice(i, 1);
+ continue;
+ }
+ // Update last known states
+ fruit.lastY = fruit.y;
+ fruit.lastIntersecting = currentIntersecting;
+ }
+ // 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
+ }
+};
+// Start background music
+LK.playMusic('bgmusic');
\ No newline at end of file