User prompt
ahora quisiera que los objetos que no podemos tocar aparezcan cada vez mas si seguimos pasando de nivel, maximo 5 objetos
User prompt
Que las flechas se borren de la infraestructura que se choco solo cuando hallamos pasado el nivel
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'active')' in or related to this line: 'if (!arrow.active) {' Line Number: 381
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'active')' in or related to this line: 'if (!arrow.active) {' Line Number: 381
User prompt
Pero al atinarle a las frutas, las flechas que se quedan en la infrastructura deberian borrarse
User prompt
Elimina la linea roja
User prompt
Quiero que esa linea roja nos indique hacia donde ira la flecha y que forma tomara ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Que esa linea tambien se doble, que se mueva, agranda o doble dependiendo de que forma tendra la flecha cuando se dispara ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Pero que lo que no podemos tocar tenga su propia plataforma
User prompt
Que sean 5 flechas y la persona este en el medio al lado izquierdo
User prompt
Ahora quisiera que pongas otro objeto que si la flecha le da, pierde el nivel
User prompt
Un poco mas de fuerza y que haya como una linea indicandonos la direccion que hara la flecha
User prompt
Un poco menos de fuerza para la flecha
User prompt
Quiero que la felcha no traspase la infraestructura donde esta la fruta
User prompt
mas potencia al disparo de la flecha y que las infraestructuras no choquen entre si
User prompt
Que el personaje y la infrestructura tengan la distancia adecuada para que la felcha les pueda dar
User prompt
Quiero que si el mouse esta mas lejos o mas cerca del personaje sea la potencia del disparo de la felcha
Code edit (1 edits merged)
Please save this source code
User prompt
Fruit Archer - Bow and Arrow Shooting Game
Initial prompt
Quisiera que una persona con arco y flecha este al lado izquierdo y que con el mouse podamos decidir la direccion donde disparara la felcha hacia infraestructuras con frutas donde la flecha le debe dar a las frutas.
/**** * 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); // 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 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; } } // 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 () { if (LK.getScore() >= targetScore) { LK.showYouWin(); } 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 maxArrows = 3; var targetScore = 200; // Position archer on the left side archer.x = 300; archer.y = 2400; 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 platforms for (var i = 0; i < platforms.length; i++) { platforms[i].destroy(); } platforms = []; var fruitTypes = ['apple', 'orange', 'banana']; var numFruits = Math.min(8, Math.floor(LK.getScore() / 50) + 4); for (var i = 0; i < numFruits; i++) { // Create platform var platform = new Platform(); platform.x = 600 + Math.random() * 800; platform.y = 1000 + Math.random() * 1200; 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); } } // 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 8, maximum 25) currentPower = Math.min(25, Math.max(8, distance / 40)); }; 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 (minimum 8, maximum 25) currentPower = Math.min(25, Math.max(8, distance / 40)); 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; 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
@@ -147,9 +147,9 @@
var platforms = [];
var maxArrows = 3;
var targetScore = 200;
// Position archer on the left side
-archer.x = 150;
+archer.x = 300;
archer.y = 2400;
game.addChild(archer);
// Create score display
var scoreTxt = new Text2('0', {
@@ -189,9 +189,9 @@
var numFruits = Math.min(8, Math.floor(LK.getScore() / 50) + 4);
for (var i = 0; i < numFruits; i++) {
// Create platform
var platform = new Platform();
- platform.x = 800 + Math.random() * 1000;
+ platform.x = 600 + Math.random() * 800;
platform.y = 1000 + Math.random() * 1200;
platforms.push(platform);
game.addChild(platform);
// Create fruit on platform
@@ -216,10 +216,10 @@
// 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 5, maximum 20)
- currentPower = Math.min(20, Math.max(5, distance / 50));
+ // Scale power based on distance (minimum 8, maximum 25)
+ currentPower = Math.min(25, Math.max(8, distance / 40));
};
game.down = function (x, y, obj) {
mouseX = x;
mouseY = y;
@@ -227,10 +227,10 @@
// 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 5, maximum 20)
- currentPower = Math.min(20, Math.max(5, distance / 50));
+ // Scale power based on distance (minimum 8, maximum 25)
+ currentPower = Math.min(25, Math.max(8, distance / 40));
archer.shoot();
// Update arrows remaining display
arrowsTxt.setText('Arrows: ' + (maxArrows - arrows.length));
};
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