User prompt
Que los niveles siempre se ppuedan pasar
User prompt
Borra la animacion de la bomba ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que las animaciones no traspacen la plataforma ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Las animaciones hacen que la fruta cada vez vaya hacia abajo, quiero que se mantengan en el mismo lugar
User prompt
Que la animacion de la bomba no se haga tan pequeña ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que todas las frutas esten animadas del nivel ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que la fruta y la bomba tengan animaciones pequeñas de movimiento en el mismo lugar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que el arrow siga la direccion del sprite
User prompt
Borra las dos ideas anteriores que te di
User prompt
Elimina eso del collider
User prompt
Que los arbustos de la plataforma no tenga collider
User prompt
Puedes poner un poquito mas abajo solo las frutas
User prompt
Ahora puedes hacer mas grande las plataformas y objetos
User prompt
UN poco mas arriba los objetps
User prompt
No en el centro de la plataforma, en el centro de arriba de la plataforma
User prompt
Que los objetos vayan en el centro de la plataforma
User prompt
Olvida ese cambio de mas grande y los objetos en el medio, borra ese cambio
User prompt
Que la plataforma sea mas grande
User prompt
Que los objetos vayan en medio del sprite de la plataforma
User prompt
Puedes hacer mas grande los objetos
User prompt
Ahora quisiera que reciba mas puntos si las felchas no caen en las plataformas
User prompt
Ahora quisiera que aparezca como un bonu que si le das, se elimine todas las frutas y pasas al suigiente nivel pero ese bonus debe aparecer muy pocas veces y que sea dificil darle
User prompt
La cantidad dde flechas que te dan cuando le das a ese bonus sea aleatorio pero maximo 5
User prompt
Ahora quisiera que haya como bonus de conseguir mas flechas pero solo si le damos con una flecha, que ese bono aparezca en diferentes niveles pero a veces no
User prompt
Que sea posible darle a las frutas en cada nivel y que cada vez se ponga poco a poco complicado
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Archer = Container.expand(function () { var self = Container.call(this); var archerGraphics = self.attachAsset('archer', { anchorX: 0.5, anchorY: 1.0 }); var bowGraphics = self.attachAsset('bow', { anchorX: 0.2, anchorY: 0.5 }); bowGraphics.x = 20; bowGraphics.y = -60; self.bow = bowGraphics; self.aimAngle = 0; self.aimAt = function (targetX, targetY) { var dx = targetX - (self.x + self.bow.x); var dy = targetY - (self.y + self.bow.y); self.aimAngle = Math.atan2(dy, dx); self.bow.rotation = self.aimAngle; }; self.shoot = function () { if (arrows.length >= maxArrows) return; var arrow = new Arrow(); var bowWorldX = self.x + self.bow.x + Math.cos(self.aimAngle) * 30; var bowWorldY = self.y + self.bow.y + Math.sin(self.aimAngle) * 30; arrow.x = bowWorldX; arrow.y = bowWorldY; arrow.rotation = self.aimAngle; var power = currentPower; // Use dynamic power based on mouse distance arrow.velocityX = Math.cos(self.aimAngle) * power; arrow.velocityY = Math.sin(self.aimAngle) * power; arrows.push(arrow); game.addChild(arrow); LK.getSound('shoot').play(); }; return self; }); var Arrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('arrow', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.gravity = 0.3; self.active = true; self.update = function () { if (!self.active) return; self.x += self.velocityX; self.y += self.velocityY; self.velocityY += self.gravity; // Update arrow rotation based on velocity self.rotation = Math.atan2(self.velocityY, self.velocityX); // Check collision with platforms for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; if (self.intersects(platform)) { self.active = false; // Stop the arrow at the platform self.velocityX = 0; self.velocityY = 0; break; } } // Remove arrow if it goes off screen if (self.x > 2100 || self.y > 2800 || self.x < -50 || self.y < -50) { self.destroy(); for (var i = arrows.length - 1; i >= 0; i--) { if (arrows[i] === self) { arrows.splice(i, 1); break; } } } }; return self; }); var ArrowBonus = Container.expand(function () { var self = Container.call(this); var bonusGraphics = self.attachAsset('arrowBonus', { anchorX: 0.5, anchorY: 0.5 }); self.hit = false; self.getHit = function () { if (self.hit) return; self.hit = true; // Add 2 extra arrows maxArrows += 2; // Flash effect LK.effects.flashObject(self, 0x00ff00, 300); // Remove from arrowBonuses array for (var i = arrowBonuses.length - 1; i >= 0; i--) { if (arrowBonuses[i] === self) { arrowBonuses.splice(i, 1); break; } } // Animate bonus disappearing tween(self, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); LK.getSound('hit').play(); // Update arrows display arrowsTxt.setText('Arrows: ' + Math.max(0, maxArrows - arrows.length)); }; return self; }); var Bomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('bomb', { anchorX: 0.5, anchorY: 0.5 }); self.hit = false; self.getHit = function () { if (self.hit) return; self.hit = true; // Flash effect LK.effects.flashObject(self, 0xff0000, 300); // Remove from bombs array for (var i = bombs.length - 1; i >= 0; i--) { if (bombs[i] === self) { bombs.splice(i, 1); break; } } // Flash screen red and show game over LK.effects.flashScreen(0xff0000, 1000); LK.getSound('explosion').play(); // Animate bomb explosion tween(self, { alpha: 0, scaleX: 2, scaleY: 2 }, { duration: 300, onFinish: function onFinish() { self.destroy(); // Show game over after explosion animation LK.setTimeout(function () { LK.showGameOver(); }, 200); } }); }; return self; }); var Fruit = Container.expand(function (type) { var self = Container.call(this); var fruitType = type || 'apple'; var fruitGraphics = self.attachAsset(fruitType, { anchorX: 0.5, anchorY: 0.5 }); self.fruitType = fruitType; self.points = fruitType === 'apple' ? 10 : fruitType === 'orange' ? 15 : 20; self.hit = false; self.getHit = function () { if (self.hit) return; self.hit = true; LK.setScore(LK.getScore() + self.points); scoreTxt.setText(LK.getScore()); // Flash effect LK.effects.flashObject(self, 0xFFFFFF, 300); // Remove from fruits array for (var i = fruits.length - 1; i >= 0; i--) { if (fruits[i] === self) { fruits.splice(i, 1); break; } } // Only remove arrows when level is completed (no fruits remain) // The arrows will be cleared when spawnFruits() is called for next level // Animate fruit disappearing tween(self, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); LK.getSound('hit').play(); // Check win condition if (fruits.length === 0) { LK.setTimeout(function () { // Calculate current level and increase target score for next level var currentLevel = Math.floor(LK.getScore() / 200) + 1; var nextTargetScore = currentLevel * 200; if (LK.getScore() >= targetScore) { // Increase target score for next level targetScore = nextTargetScore + 200; targetTxt.setText('Target: ' + targetScore); spawnFruits(); } else { spawnFruits(); } }, 500); } }; return self; }); var Platform = Container.expand(function () { var self = Container.call(this); var platformGraphics = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var archer = new Archer(); var arrows = []; var fruits = []; var platforms = []; var bombs = []; var arrowBonuses = []; var maxArrows = 5; var targetScore = 200; // Position archer in the middle-left area archer.x = 300; archer.y = 1366; // Middle of screen vertically (2732/2) game.addChild(archer); // Create score display var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create target score display var targetTxt = new Text2('Target: ' + targetScore, { size: 60, fill: 0xFFFF00 }); targetTxt.anchor.set(1, 0); targetTxt.y = 120; LK.gui.topRight.addChild(targetTxt); // Create arrows remaining display var arrowsTxt = new Text2('Arrows: ' + maxArrows, { size: 60, fill: 0xFFFFFF }); arrowsTxt.anchor.set(0, 0); arrowsTxt.y = 120; LK.gui.topLeft.addChild(arrowsTxt); function spawnFruits() { // Clear existing fruits for (var i = 0; i < fruits.length; i++) { fruits[i].destroy(); } fruits = []; // Clear existing bombs for (var i = 0; i < bombs.length; i++) { bombs[i].destroy(); } bombs = []; // Clear existing arrow bonuses for (var i = 0; i < arrowBonuses.length; i++) { arrowBonuses[i].destroy(); } arrowBonuses = []; // Clear all arrows (including those stuck on platforms) for (var i = 0; i < arrows.length; i++) { arrows[i].destroy(); } arrows = []; // Decrease max arrows as levels progress (start with 6, minimum 3) var currentLevel = Math.floor(LK.getScore() / 200) + 1; maxArrows = Math.max(3, 6 - Math.floor(currentLevel / 2)); // Clear existing platforms for (var i = 0; i < platforms.length; i++) { platforms[i].destroy(); } platforms = []; var fruitTypes = ['apple', 'orange', 'banana']; // Calculate level based on score progression var currentLevel = Math.floor(LK.getScore() / 200) + 1; // Increase number of fruits with each level (start with 3, add 1 per level, max 10) var numFruits = Math.min(10, 3 + currentLevel); for (var i = 0; i < numFruits; i++) { // Create platform with collision detection var platform = new Platform(); var validPosition = false; var attempts = 0; while (!validPosition && attempts < 50) { // Make platforms more spread out and harder to reach in higher levels var currentLevel = Math.floor(LK.getScore() / 200) + 1; var spreadFactor = Math.min(2, 1 + currentLevel * 0.2); platform.x = 600 + Math.random() * (800 * spreadFactor); platform.y = 800 + Math.random() * (1400 * spreadFactor); validPosition = true; // Check collision with existing platforms for (var j = 0; j < platforms.length; j++) { var existingPlatform = platforms[j]; var dx = platform.x - existingPlatform.x; var dy = platform.y - existingPlatform.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 200) { // Minimum distance between platforms validPosition = false; break; } } attempts++; } platforms.push(platform); game.addChild(platform); // Create fruit on platform var fruitType = fruitTypes[Math.floor(Math.random() * fruitTypes.length)]; var fruit = new Fruit(fruitType); fruit.x = platform.x; fruit.y = platform.y - 35; fruits.push(fruit); game.addChild(fruit); } // Create separate platforms for bombs // Calculate level based on score progression (every 200 points is roughly a level) var currentLevel = Math.floor(LK.getScore() / 200) + 1; // Increase bomb count with each level, starting with 1, maximum 5 var numBombs = Math.min(5, currentLevel); for (var i = 0; i < numBombs; i++) { // Create bomb platform with collision detection var bombPlatform = new Platform(); var validPosition = false; var attempts = 0; while (!validPosition && attempts < 50) { // Make bomb platforms more spread out and harder to avoid in higher levels var currentLevel = Math.floor(LK.getScore() / 200) + 1; var spreadFactor = Math.min(2, 1 + currentLevel * 0.2); bombPlatform.x = 600 + Math.random() * (800 * spreadFactor); bombPlatform.y = 800 + Math.random() * (1400 * spreadFactor); validPosition = true; // Check collision with existing platforms (both fruit and bomb platforms) for (var j = 0; j < platforms.length; j++) { var existingPlatform = platforms[j]; var dx = bombPlatform.x - existingPlatform.x; var dy = bombPlatform.y - existingPlatform.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 200) { // Minimum distance between platforms validPosition = false; break; } } attempts++; } platforms.push(bombPlatform); game.addChild(bombPlatform); // Create bomb on its own platform var bomb = new Bomb(); bomb.x = bombPlatform.x; bomb.y = bombPlatform.y - 35; bombs.push(bomb); game.addChild(bomb); } // Create arrow bonuses (only sometimes, based on level) var currentLevel = Math.floor(LK.getScore() / 200) + 1; // 60% chance to spawn arrow bonus, but only every 2-3 levels var shouldSpawnBonus = Math.random() < 0.6 && currentLevel > 1 && (currentLevel % 2 === 0 || currentLevel % 3 === 0); if (shouldSpawnBonus) { // Create arrow bonus platform with collision detection var bonusPlatform = new Platform(); var validPosition = false; var attempts = 0; while (!validPosition && attempts < 50) { bonusPlatform.x = 600 + Math.random() * 800; bonusPlatform.y = 800 + Math.random() * 1400; validPosition = true; // Check collision with existing platforms for (var j = 0; j < platforms.length; j++) { var existingPlatform = platforms[j]; var dx = bonusPlatform.x - existingPlatform.x; var dy = bonusPlatform.y - existingPlatform.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < 200) { validPosition = false; break; } } attempts++; } platforms.push(bonusPlatform); game.addChild(bonusPlatform); // Create arrow bonus on platform var arrowBonus = new ArrowBonus(); arrowBonus.x = bonusPlatform.x; arrowBonus.y = bonusPlatform.y - 35; arrowBonuses.push(arrowBonus); game.addChild(arrowBonus); } } // Initialize first level spawnFruits(); // Mouse controls var mouseX = 0; var mouseY = 0; var currentPower = 12; // Default power game.move = function (x, y, obj) { mouseX = x; mouseY = y; archer.aimAt(x, y); // Calculate power based on distance from archer var dx = x - archer.x; var dy = y - archer.y; var distance = Math.sqrt(dx * dx + dy * dy); // Scale power based on distance (minimum 12, maximum 28) currentPower = Math.min(28, Math.max(12, distance / 25)); }; game.down = function (x, y, obj) { mouseX = x; mouseY = y; archer.aimAt(x, y); // Calculate power based on distance from archer var dx = x - archer.x; var dy = y - archer.y; var distance = Math.sqrt(dx * dx + dy * dy); // Scale power based on distance from archer (minimum 12, maximum 28) currentPower = Math.min(28, Math.max(12, distance / 25)); archer.shoot(); // Update arrows remaining display arrowsTxt.setText('Arrows: ' + (maxArrows - arrows.length)); }; game.update = function () { // Check arrow-fruit collisions for (var i = arrows.length - 1; i >= 0; i--) { var arrow = arrows[i]; if (!arrow.active) continue; // Check bomb collisions first for (var j = 0; j < bombs.length; j++) { var bomb = bombs[j]; if (!bomb.hit && arrow.intersects(bomb)) { arrow.active = false; bomb.getHit(); arrow.destroy(); arrows.splice(i, 1); return; // Exit immediately as game will be over } } // Check arrow bonus collisions for (var j = 0; j < arrowBonuses.length; j++) { var arrowBonus = arrowBonuses[j]; if (!arrowBonus.hit && arrow.intersects(arrowBonus)) { arrow.active = false; arrowBonus.getHit(); arrow.destroy(); arrows.splice(i, 1); break; } } for (var j = 0; j < fruits.length; j++) { var fruit = fruits[j]; if (!fruit.hit && arrow.intersects(fruit)) { arrow.active = false; fruit.getHit(); arrow.destroy(); arrows.splice(i, 1); break; } } } // Check if out of arrows and no fruits hit recently if (arrows.length >= maxArrows && fruits.length > 0) { var allArrowsStopped = true; for (var i = 0; i < arrows.length; i++) { if (arrows[i].active && (Math.abs(arrows[i].velocityX) > 0.5 || Math.abs(arrows[i].velocityY) > 0.5)) { allArrowsStopped = false; break; } } if (allArrowsStopped) { // Clear all arrows for (var i = 0; i < arrows.length; i++) { arrows[i].destroy(); } arrows = []; arrowsTxt.setText('Arrows: ' + maxArrows); // Check if we have enough score to win if (LK.getScore() >= targetScore) { LK.showYouWin(); } else if (fruits.length > 0) { // Game over if we still have fruits but no arrows LK.showGameOver(); } } } // Update arrows remaining display arrowsTxt.setText('Arrows: ' + Math.max(0, maxArrows - arrows.length)); };
===================================================================
--- original.js
+++ change.js
@@ -83,8 +83,46 @@
}
};
return self;
});
+var ArrowBonus = Container.expand(function () {
+ var self = Container.call(this);
+ var bonusGraphics = self.attachAsset('arrowBonus', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.hit = false;
+ self.getHit = function () {
+ if (self.hit) return;
+ self.hit = true;
+ // Add 2 extra arrows
+ maxArrows += 2;
+ // Flash effect
+ LK.effects.flashObject(self, 0x00ff00, 300);
+ // Remove from arrowBonuses array
+ for (var i = arrowBonuses.length - 1; i >= 0; i--) {
+ if (arrowBonuses[i] === self) {
+ arrowBonuses.splice(i, 1);
+ break;
+ }
+ }
+ // Animate bonus disappearing
+ tween(self, {
+ alpha: 0,
+ scaleX: 0.1,
+ scaleY: 0.1
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ LK.getSound('hit').play();
+ // Update arrows display
+ arrowsTxt.setText('Arrows: ' + Math.max(0, maxArrows - arrows.length));
+ };
+ return self;
+});
var Bomb = Container.expand(function () {
var self = Container.call(this);
var bombGraphics = self.attachAsset('bomb', {
anchorX: 0.5,
@@ -204,8 +242,9 @@
var arrows = [];
var fruits = [];
var platforms = [];
var bombs = [];
+var arrowBonuses = [];
var maxArrows = 5;
var targetScore = 200;
// Position archer in the middle-left area
archer.x = 300;
@@ -244,8 +283,13 @@
for (var i = 0; i < bombs.length; i++) {
bombs[i].destroy();
}
bombs = [];
+ // Clear existing arrow bonuses
+ for (var i = 0; i < arrowBonuses.length; i++) {
+ arrowBonuses[i].destroy();
+ }
+ arrowBonuses = [];
// Clear all arrows (including those stuck on platforms)
for (var i = 0; i < arrows.length; i++) {
arrows[i].destroy();
}
@@ -338,8 +382,43 @@
bomb.y = bombPlatform.y - 35;
bombs.push(bomb);
game.addChild(bomb);
}
+ // Create arrow bonuses (only sometimes, based on level)
+ var currentLevel = Math.floor(LK.getScore() / 200) + 1;
+ // 60% chance to spawn arrow bonus, but only every 2-3 levels
+ var shouldSpawnBonus = Math.random() < 0.6 && currentLevel > 1 && (currentLevel % 2 === 0 || currentLevel % 3 === 0);
+ if (shouldSpawnBonus) {
+ // Create arrow bonus platform with collision detection
+ var bonusPlatform = new Platform();
+ var validPosition = false;
+ var attempts = 0;
+ while (!validPosition && attempts < 50) {
+ bonusPlatform.x = 600 + Math.random() * 800;
+ bonusPlatform.y = 800 + Math.random() * 1400;
+ validPosition = true;
+ // Check collision with existing platforms
+ for (var j = 0; j < platforms.length; j++) {
+ var existingPlatform = platforms[j];
+ var dx = bonusPlatform.x - existingPlatform.x;
+ var dy = bonusPlatform.y - existingPlatform.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 200) {
+ validPosition = false;
+ break;
+ }
+ }
+ attempts++;
+ }
+ platforms.push(bonusPlatform);
+ game.addChild(bonusPlatform);
+ // Create arrow bonus on platform
+ var arrowBonus = new ArrowBonus();
+ arrowBonus.x = bonusPlatform.x;
+ arrowBonus.y = bonusPlatform.y - 35;
+ arrowBonuses.push(arrowBonus);
+ game.addChild(arrowBonus);
+ }
}
// Initialize first level
spawnFruits();
// Mouse controls
@@ -386,8 +465,19 @@
arrows.splice(i, 1);
return; // Exit immediately as game will be over
}
}
+ // Check arrow bonus collisions
+ for (var j = 0; j < arrowBonuses.length; j++) {
+ var arrowBonus = arrowBonuses[j];
+ if (!arrowBonus.hit && arrow.intersects(arrowBonus)) {
+ arrow.active = false;
+ arrowBonus.getHit();
+ arrow.destroy();
+ arrows.splice(i, 1);
+ break;
+ }
+ }
for (var j = 0; j < fruits.length; j++) {
var fruit = fruits[j];
if (!fruit.hit && arrow.intersects(fruit)) {
arrow.active = false;
Estrella animada. In-Game asset. 2d. High contrast. No shadows
Estrella. In-Game asset. 2d. High contrast. No shadows
Nube. In-Game asset. 2d. High contrast. No shadows
Bush. In-Game asset. 2d. High contrast. No shadows
tree. In-Game asset. 2d. High contrast. No shadows
Quita los arboles y las nubes
Boton de start. In-Game asset. 2d. High contrast. No shadows
Fondo para un juego de fruit archer. In-Game asset. 2d. High contrast. No shadows
Fruit Archer titulo. In-Game asset. 2d. High contrast. No shadows