User prompt
Mejor me este dos lanza guisantes diferentes equipos
User prompt
Ahora lanza guisantes también será de mi equipo
User prompt
Mejor que los bots vayan por todo el campo y no en su propio campo
User prompt
Que los bots vayan también a la cancha contraria para meter gol
User prompt
Pero que no se choquen con el borde los bots y cuando tengan la pelota, que vaya a la portería para meter gol
User prompt
Que los bots también metan tiros a la portería y también quitar la pelota al contricante
User prompt
Pero porque lanza guisantes no dispara su guisante. Arregla ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Pon un borde alrededor de la pantalla y que no se choquen los bots
User prompt
Pero que jueguen bien al fútbol los bots y se pueden pasar al pelota
User prompt
Pero que el guisante hace que alguien toque que no se mueva por 3 segundos. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Cuando alguien se choca con otro. Ellos rebotan. Y cuando alguien toque el guisante, será aturdido por 3 segundos y que los bots metan gol. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agrega al lanza guisantes (qué será un bot o ia qué sabrá jugar al fútbol). Que su habilidad es disparar un guisante qué va recto (solo usa su habilidad cuando tenga la pelota o balón). Para diferenciar qué alguien no es de tu equipo, tus enemigos tendrán un borde rojo que significa que es tu enemigo. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Goal Strike Arena
Initial prompt
Es un juego al estilo fútbol. A arriba hay una portería y en la abajo hay otra portería. Los personajes tienen habilidades que pueden usarse para meter gol.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 0;
self.velocityY = 0;
self.friction = 0.98;
self.bounceStrength = 0.8;
self.kick = function (forceX, forceY) {
self.velocityX += forceX;
self.velocityY += forceY;
LK.getSound('kick').play();
};
self.update = function () {
self.x += self.velocityX;
self.y += self.velocityY;
self.velocityX *= self.friction;
self.velocityY *= self.friction;
// Bounce off walls
if (self.x <= 20 || self.x >= 2028) {
self.velocityX *= -self.bounceStrength;
self.x = Math.max(20, Math.min(2028, self.x));
}
// Check goal areas
if (self.y <= 100 && self.x >= 874 && self.x <= 1174) {
// Top goal (opponent scores)
if (!self.goalScored) {
self.goalScored = true;
opponentScore++;
LK.getSound('goal').play();
LK.effects.flashScreen(0xff4500, 500);
resetBall();
}
} else if (self.y >= 2632 && self.x >= 874 && self.x <= 1174) {
// Bottom goal (player scores)
if (!self.goalScored) {
self.goalScored = true;
playerScore++;
LK.getSound('goal').play();
LK.effects.flashScreen(0x4169e1, 500);
resetBall();
}
} else {
self.goalScored = false;
}
// Bounce off top and bottom (outside goal areas)
if (self.y <= 20 && (self.x < 874 || self.x > 1174) || self.y >= 2712 && (self.x < 874 || self.x > 1174)) {
self.velocityY *= -self.bounceStrength;
self.y = Math.max(20, Math.min(2712, self.y));
}
};
return self;
});
var Opponent = Container.expand(function () {
var self = Container.call(this);
var opponentGraphics = self.attachAsset('opponent', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.targetX = 1024;
self.targetY = 500;
self.aiTimer = 0;
self.update = function () {
self.aiTimer++;
// Simple AI: move towards ball or defensive position
if (ball.y < 1366) {
// Ball in opponent's half
self.targetX = ball.x;
self.targetY = ball.y + 100;
} else {
self.targetX = 1024;
self.targetY = 500;
}
// Move towards target
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Keep opponent in their half mostly
self.y = Math.max(100, Math.min(1300, self.y));
self.x = Math.max(100, Math.min(1948, self.x));
// Check ball collision
var ballDistance = Math.sqrt(Math.pow(ball.x - self.x, 2) + Math.pow(ball.y - self.y, 2));
if (ballDistance < 50) {
var kickForceX = (ball.x - self.x) / ballDistance * 6;
var kickForceY = (ball.y - self.y) / ballDistance * 6;
ball.kick(kickForceX, kickForceY);
}
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 4;
self.targetX = 1024;
self.targetY = 2200;
self.abilityType = 'speed'; // 'speed', 'power', 'shield'
self.abilityCooldown = 0;
self.abilityDuration = 0;
self.abilityEffect = null;
self.activateAbility = function () {
if (self.abilityCooldown <= 0) {
self.abilityCooldown = 180; // 3 seconds at 60fps
self.abilityDuration = 120; // 2 seconds effect
LK.getSound('ability').play();
if (self.abilityType === 'speed') {
self.abilityEffect = self.addChild(LK.getAsset('speedBoostEffect', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.7
}));
self.speed = 8;
}
}
};
self.update = function () {
// Move towards target
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Update ability
if (self.abilityDuration > 0) {
self.abilityDuration--;
if (self.abilityEffect) {
self.abilityEffect.rotation += 0.1;
}
} else {
if (self.abilityEffect) {
self.removeChild(self.abilityEffect);
self.abilityEffect = null;
}
self.speed = 4;
}
if (self.abilityCooldown > 0) {
self.abilityCooldown--;
}
// Check ball collision
var ballDistance = Math.sqrt(Math.pow(ball.x - self.x, 2) + Math.pow(ball.y - self.y, 2));
if (ballDistance < 50) {
var kickForceX = (ball.x - self.x) / ballDistance * 8;
var kickForceY = (ball.y - self.y) / ballDistance * 8;
if (self.abilityType === 'power' && self.abilityDuration > 0) {
kickForceX *= 2;
kickForceY *= 2;
}
ball.kick(kickForceX, kickForceY);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228b22
});
/****
* Game Code
****/
// Game variables
var playerScore = 0;
var opponentScore = 0;
var targetScore = 3;
var ball;
var player;
var opponent;
// Create field elements
var field = game.addChild(LK.getAsset('field', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
var centerLine = game.addChild(LK.getAsset('centerLine', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var centerCircle = game.addChild(LK.getAsset('centerCircle', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
alpha: 0.3
}));
// Create goals
var topGoal = game.addChild(LK.getAsset('topGoal', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 50
}));
var bottomGoal = game.addChild(LK.getAsset('bottomGoal', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 2682
}));
// Create score display
var scoreText = new Text2('Player: 0 - Opponent: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create ability button
var abilityButton = new Text2('SPEED BOOST', {
size: 40,
fill: 0xFFFF00
});
abilityButton.anchor.set(0.5, 1);
LK.gui.bottom.addChild(abilityButton);
// Create game objects
ball = game.addChild(new Ball());
player = game.addChild(new Player());
opponent = game.addChild(new Opponent());
function resetBall() {
LK.setTimeout(function () {
ball.x = 1024;
ball.y = 1366;
ball.velocityX = 0;
ball.velocityY = 0;
ball.goalScored = false;
// Update score display
scoreText.setText('Player: ' + playerScore + ' - Opponent: ' + opponentScore);
// Check win condition
if (playerScore >= targetScore) {
LK.showYouWin();
} else if (opponentScore >= targetScore) {
LK.showGameOver();
}
}, 1000);
}
// Initialize positions
resetBall();
player.x = 1024;
player.y = 2200;
opponent.x = 1024;
opponent.y = 500;
// Touch controls
game.down = function (x, y, obj) {
player.targetX = x;
player.targetY = y;
};
game.move = function (x, y, obj) {
player.targetX = x;
player.targetY = y;
};
// Ability button handler
abilityButton.down = function (x, y, obj) {
player.activateAbility();
};
game.update = function () {
// Update ability button text
if (player.abilityCooldown > 0) {
abilityButton.setText('COOLDOWN: ' + Math.ceil(player.abilityCooldown / 60));
abilityButton.tint = 0x666666;
} else {
abilityButton.setText('SPEED BOOST');
abilityButton.tint = 0xffff00;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,287 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Ball = Container.expand(function () {
+ var self = Container.call(this);
+ var ballGraphics = self.attachAsset('ball', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocityX = 0;
+ self.velocityY = 0;
+ self.friction = 0.98;
+ self.bounceStrength = 0.8;
+ self.kick = function (forceX, forceY) {
+ self.velocityX += forceX;
+ self.velocityY += forceY;
+ LK.getSound('kick').play();
+ };
+ self.update = function () {
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ self.velocityX *= self.friction;
+ self.velocityY *= self.friction;
+ // Bounce off walls
+ if (self.x <= 20 || self.x >= 2028) {
+ self.velocityX *= -self.bounceStrength;
+ self.x = Math.max(20, Math.min(2028, self.x));
+ }
+ // Check goal areas
+ if (self.y <= 100 && self.x >= 874 && self.x <= 1174) {
+ // Top goal (opponent scores)
+ if (!self.goalScored) {
+ self.goalScored = true;
+ opponentScore++;
+ LK.getSound('goal').play();
+ LK.effects.flashScreen(0xff4500, 500);
+ resetBall();
+ }
+ } else if (self.y >= 2632 && self.x >= 874 && self.x <= 1174) {
+ // Bottom goal (player scores)
+ if (!self.goalScored) {
+ self.goalScored = true;
+ playerScore++;
+ LK.getSound('goal').play();
+ LK.effects.flashScreen(0x4169e1, 500);
+ resetBall();
+ }
+ } else {
+ self.goalScored = false;
+ }
+ // Bounce off top and bottom (outside goal areas)
+ if (self.y <= 20 && (self.x < 874 || self.x > 1174) || self.y >= 2712 && (self.x < 874 || self.x > 1174)) {
+ self.velocityY *= -self.bounceStrength;
+ self.y = Math.max(20, Math.min(2712, self.y));
+ }
+ };
+ return self;
+});
+var Opponent = Container.expand(function () {
+ var self = Container.call(this);
+ var opponentGraphics = self.attachAsset('opponent', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 3;
+ self.targetX = 1024;
+ self.targetY = 500;
+ self.aiTimer = 0;
+ self.update = function () {
+ self.aiTimer++;
+ // Simple AI: move towards ball or defensive position
+ if (ball.y < 1366) {
+ // Ball in opponent's half
+ self.targetX = ball.x;
+ self.targetY = ball.y + 100;
+ } else {
+ self.targetX = 1024;
+ self.targetY = 500;
+ }
+ // Move towards target
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ // Keep opponent in their half mostly
+ self.y = Math.max(100, Math.min(1300, self.y));
+ self.x = Math.max(100, Math.min(1948, self.x));
+ // Check ball collision
+ var ballDistance = Math.sqrt(Math.pow(ball.x - self.x, 2) + Math.pow(ball.y - self.y, 2));
+ if (ballDistance < 50) {
+ var kickForceX = (ball.x - self.x) / ballDistance * 6;
+ var kickForceY = (ball.y - self.y) / ballDistance * 6;
+ ball.kick(kickForceX, kickForceY);
+ }
+ };
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4;
+ self.targetX = 1024;
+ self.targetY = 2200;
+ self.abilityType = 'speed'; // 'speed', 'power', 'shield'
+ self.abilityCooldown = 0;
+ self.abilityDuration = 0;
+ self.abilityEffect = null;
+ self.activateAbility = function () {
+ if (self.abilityCooldown <= 0) {
+ self.abilityCooldown = 180; // 3 seconds at 60fps
+ self.abilityDuration = 120; // 2 seconds effect
+ LK.getSound('ability').play();
+ if (self.abilityType === 'speed') {
+ self.abilityEffect = self.addChild(LK.getAsset('speedBoostEffect', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.7
+ }));
+ self.speed = 8;
+ }
+ }
+ };
+ self.update = function () {
+ // Move towards target
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ // Update ability
+ if (self.abilityDuration > 0) {
+ self.abilityDuration--;
+ if (self.abilityEffect) {
+ self.abilityEffect.rotation += 0.1;
+ }
+ } else {
+ if (self.abilityEffect) {
+ self.removeChild(self.abilityEffect);
+ self.abilityEffect = null;
+ }
+ self.speed = 4;
+ }
+ if (self.abilityCooldown > 0) {
+ self.abilityCooldown--;
+ }
+ // Check ball collision
+ var ballDistance = Math.sqrt(Math.pow(ball.x - self.x, 2) + Math.pow(ball.y - self.y, 2));
+ if (ballDistance < 50) {
+ var kickForceX = (ball.x - self.x) / ballDistance * 8;
+ var kickForceY = (ball.y - self.y) / ballDistance * 8;
+ if (self.abilityType === 'power' && self.abilityDuration > 0) {
+ kickForceX *= 2;
+ kickForceY *= 2;
+ }
+ ball.kick(kickForceX, kickForceY);
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x228b22
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var playerScore = 0;
+var opponentScore = 0;
+var targetScore = 3;
+var ball;
+var player;
+var opponent;
+// Create field elements
+var field = game.addChild(LK.getAsset('field', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+}));
+var centerLine = game.addChild(LK.getAsset('centerLine', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366
+}));
+var centerCircle = game.addChild(LK.getAsset('centerCircle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 1366,
+ alpha: 0.3
+}));
+// Create goals
+var topGoal = game.addChild(LK.getAsset('topGoal', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 50
+}));
+var bottomGoal = game.addChild(LK.getAsset('bottomGoal', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 2682
+}));
+// Create score display
+var scoreText = new Text2('Player: 0 - Opponent: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreText);
+// Create ability button
+var abilityButton = new Text2('SPEED BOOST', {
+ size: 40,
+ fill: 0xFFFF00
+});
+abilityButton.anchor.set(0.5, 1);
+LK.gui.bottom.addChild(abilityButton);
+// Create game objects
+ball = game.addChild(new Ball());
+player = game.addChild(new Player());
+opponent = game.addChild(new Opponent());
+function resetBall() {
+ LK.setTimeout(function () {
+ ball.x = 1024;
+ ball.y = 1366;
+ ball.velocityX = 0;
+ ball.velocityY = 0;
+ ball.goalScored = false;
+ // Update score display
+ scoreText.setText('Player: ' + playerScore + ' - Opponent: ' + opponentScore);
+ // Check win condition
+ if (playerScore >= targetScore) {
+ LK.showYouWin();
+ } else if (opponentScore >= targetScore) {
+ LK.showGameOver();
+ }
+ }, 1000);
+}
+// Initialize positions
+resetBall();
+player.x = 1024;
+player.y = 2200;
+opponent.x = 1024;
+opponent.y = 500;
+// Touch controls
+game.down = function (x, y, obj) {
+ player.targetX = x;
+ player.targetY = y;
+};
+game.move = function (x, y, obj) {
+ player.targetX = x;
+ player.targetY = y;
+};
+// Ability button handler
+abilityButton.down = function (x, y, obj) {
+ player.activateAbility();
+};
+game.update = function () {
+ // Update ability button text
+ if (player.abilityCooldown > 0) {
+ abilityButton.setText('COOLDOWN: ' + Math.ceil(player.abilityCooldown / 60));
+ abilityButton.tint = 0x666666;
+ } else {
+ abilityButton.setText('SPEED BOOST');
+ abilityButton.tint = 0xffff00;
+ }
+};
\ No newline at end of file