User prompt
No me cambiaron nada sigue igual
User prompt
Está mal
User prompt
Que haya un botón de moverse
User prompt
Que haya botones para moverse y para saltar y pegar
User prompt
Que tenga botones de moverse y de a y b para saltar y pegar
Code edit (1 edits merged)
Please save this source code
User prompt
Messi vs Ronaldo: Epic Soccer Duel
Initial prompt
Quiero que hagas un juego de peleas entre Messi y Ronaldo
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var AttackEffect = Container.expand(function () { var self = Container.call(this); var effectGraphics = self.attachAsset('attack_effect', { anchorX: 0.5, anchorY: 0.5 }); self.lifetime = 20; // Scale and fade animation tween(effectGraphics, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 300 }); self.update = function () { self.lifetime--; }; return self; }); var ControlButton = Container.expand(function (label, x, y) { var self = Container.call(this); var buttonBg = self.attachAsset('button_bg', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2 }); var buttonText = new Text2(label, { size: 50, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.x = x; self.y = y; self.isPressed = false; self.setPressed = function (pressed) { self.isPressed = pressed; buttonBg.tint = pressed ? 0x00FF00 : 0xFFFFFF; buttonBg.scaleX = pressed ? 1.0 : 1.2; buttonBg.scaleY = pressed ? 1.0 : 1.2; }; return self; }); var HealthBar = Container.expand(function (isPlayer1) { var self = Container.call(this); var bgGraphics = self.attachAsset('health_bg', { anchorX: isPlayer1 ? 0 : 1, anchorY: 0 }); var fillGraphics = self.attachAsset('health_fill', { anchorX: isPlayer1 ? 0 : 1, anchorY: 0 }); self.updateHealth = function (health, maxHealth) { var healthPercent = health / maxHealth; fillGraphics.scaleX = healthPercent; // Change color based on health if (healthPercent > 0.6) { fillGraphics.tint = 0x00ff00; // Green } else if (healthPercent > 0.3) { fillGraphics.tint = 0xffff00; // Yellow } else { fillGraphics.tint = 0xff0000; // Red } }; return self; }); var Player = Container.expand(function (playerType) { var self = Container.call(this); self.playerType = playerType; self.maxHealth = 100; self.health = 100; self.power = 0; self.isBlocking = false; self.attackCooldown = 0; self.specialCooldown = 0; self.moveSpeed = 8; self.isJumping = false; self.jumpSpeed = 0; self.groundY = 2200; self.gravity = 1.2; var playerGraphics = self.attachAsset(playerType, { anchorX: 0.5, anchorY: 1.0 }); self.takeDamage = function (damage) { if (self.isBlocking) { damage = damage * 0.3; // Reduce damage when blocking } self.health -= damage; if (self.health < 0) self.health = 0; // Flash red when taking damage LK.effects.flashObject(self, 0xff0000, 300); // Screen shake on heavy damage if (damage > 15) { LK.effects.flashScreen(0xff0000, 200); } }; self.attack = function () { if (self.attackCooldown > 0) return false; self.attackCooldown = 30; // 0.5 second cooldown // Attack animation tween(playerGraphics, { scaleX: 1.2, scaleY: 0.9 }, { duration: 150, onFinish: function onFinish() { tween(playerGraphics, { scaleX: 1.0, scaleY: 1.0 }, { duration: 150 }); } }); LK.getSound('punch').play(); return true; }; self.specialAttack = function () { if (self.specialCooldown > 0 || self.power < 50) return false; self.specialCooldown = 120; // 2 second cooldown self.power -= 50; // Special attack animation tween(playerGraphics, { rotation: Math.PI * 2 }, { duration: 500, onFinish: function onFinish() { playerGraphics.rotation = 0; } }); LK.getSound('kick').play(); return true; }; self.block = function (blocking) { self.isBlocking = blocking; playerGraphics.tint = blocking ? 0x8888ff : 0xffffff; }; self.addPower = function (amount) { self.power += amount; if (self.power > 100) self.power = 100; }; self.moveLeft = function () { self.x -= self.moveSpeed; if (self.x < 75) self.x = 75; // Keep within bounds }; self.moveRight = function () { self.x += self.moveSpeed; if (self.x > 1973) self.x = 1973; // Keep within bounds }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.jumpSpeed = -20; // Negative for upward movement } }; self.update = function () { if (self.attackCooldown > 0) self.attackCooldown--; if (self.specialCooldown > 0) self.specialCooldown--; // Handle jumping physics if (self.isJumping) { self.y += self.jumpSpeed; self.jumpSpeed += self.gravity; // Check if landed if (self.y >= self.groundY) { self.y = self.groundY; self.isJumping = false; self.jumpSpeed = 0; } } }; return self; }); var SoccerBall = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('soccer_ball', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.lifetime = 300; // 5 seconds // Floating animation tween(self, { y: self.y - 20 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(self, { y: self.y + 20 }, { duration: 1000, easing: tween.easeInOut }); } }); self.update = function () { self.lifetime--; if (self.lifetime <= 0) { self.collected = true; } // Fade out in last second if (self.lifetime < 60) { ballGraphics.alpha = self.lifetime / 60; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x228b22 }); /**** * Game Code ****/ var gameState = 'playing'; // 'playing', 'gameover' var player1, player2; var soccerBalls = []; var attackEffects = []; var player1HealthBar, player2HealthBar; var powerBar1, powerBar2; var ballSpawnTimer = 0; // Create players player1 = game.addChild(new Player('messi')); player1.x = 400; player1.y = 2200; player2 = game.addChild(new Player('ronaldo')); player2.x = 1650; player2.y = 2200; // Create health bars player1HealthBar = new HealthBar(true); player1HealthBar.x = 50; player1HealthBar.y = 50; LK.gui.topLeft.addChild(player1HealthBar); player2HealthBar = new HealthBar(false); player2HealthBar.x = LK.gui.width - 50; player2HealthBar.y = 50; LK.gui.topLeft.addChild(player2HealthBar); // Create power bars (smaller, below health bars) var powerBg1 = LK.getAsset('health_bg', { scaleX: 0.5, scaleY: 0.7 }); var powerFill1 = LK.getAsset('health_fill', { scaleX: 0, scaleY: 0.7 }); powerFill1.tint = 0x0088ff; powerBar1 = new Container(); powerBar1.addChild(powerBg1); powerBar1.addChild(powerFill1); powerBar1.x = 50; powerBar1.y = 90; LK.gui.topLeft.addChild(powerBar1); var powerBg2 = LK.getAsset('health_bg', { scaleX: -0.5, scaleY: 0.7, anchorX: 1 }); var powerFill2 = LK.getAsset('health_fill', { scaleX: 0, scaleY: 0.7, anchorX: 1 }); powerFill2.tint = 0x0088ff; powerBar2 = new Container(); powerBar2.addChild(powerBg2); powerBar2.addChild(powerFill2); powerBar2.x = LK.gui.width - 50; powerBar2.y = 90; LK.gui.topLeft.addChild(powerBar2); // Game title var titleText = new Text2('MESSI vs RONALDO', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); LK.gui.top.addChild(titleText); // Instructions var instructText = new Text2('Use buttons to MOVE, JUMP (A), and ATTACK (B)', { size: 35, fill: 0xFFFFFF }); instructText.anchor.set(0.5, 1); instructText.y = LK.gui.height - 300; LK.gui.bottom.addChild(instructText); // Touch controls var isHolding = false; var holdTimer = 0; var touchStartTime = 0; // Control buttons - Player 1 (left side) var player1Controls = { moveLeft: new ControlButton('←', 120, LK.gui.height - 120), moveRight: new ControlButton('→', 220, LK.gui.height - 120), jump: new ControlButton('A', 120, LK.gui.height - 220), attack: new ControlButton('B', 220, LK.gui.height - 220) }; // Control buttons - Player 2 (right side) var player2Controls = { moveLeft: new ControlButton('←', LK.gui.width - 220, LK.gui.height - 120), moveRight: new ControlButton('→', LK.gui.width - 120, LK.gui.height - 120), jump: new ControlButton('A', LK.gui.width - 220, LK.gui.height - 220), attack: new ControlButton('B', LK.gui.width - 120, LK.gui.height - 220) }; // Add control buttons to GUI LK.gui.bottomLeft.addChild(player1Controls.moveLeft); LK.gui.bottomLeft.addChild(player1Controls.moveRight); LK.gui.bottomLeft.addChild(player1Controls.jump); LK.gui.bottomLeft.addChild(player1Controls.attack); LK.gui.bottomRight.addChild(player2Controls.moveLeft); LK.gui.bottomRight.addChild(player2Controls.moveRight); LK.gui.bottomRight.addChild(player2Controls.jump); LK.gui.bottomRight.addChild(player2Controls.attack); // Control states var controlStates = { p1MoveLeft: false, p1MoveRight: false, p1Jump: false, p1Attack: false, p2MoveLeft: false, p2MoveRight: false, p2Jump: false, p2Attack: false }; function spawnSoccerBall() { var ball = new SoccerBall(); ball.x = 1024; // Center of field ball.y = 1500 + Math.random() * 400; soccerBalls.push(ball); game.addChild(ball); } function createAttackEffect(x, y) { var effect = new AttackEffect(); effect.x = x; effect.y = y; attackEffects.push(effect); game.addChild(effect); } function checkCollisions() { // Player attacks var distance = Math.abs(player1.x - player2.x); if (distance < 200) { // Close enough for combat // Player 1 can hit Player 2 if (player1.attackCooldown === 29) { // Just attacked player2.takeDamage(15); createAttackEffect(player2.x, player2.y - 100); } // Player 2 can hit Player 1 if (player2.attackCooldown === 29) { // Just attacked player1.takeDamage(15); createAttackEffect(player1.x, player1.y - 100); } } // Special attacks have longer range if (distance < 300) { if (player1.specialCooldown === 119) { // Just used special player2.takeDamage(30); createAttackEffect(player2.x, player2.y - 100); } if (player2.specialCooldown === 119) { // Just used special player1.takeDamage(30); createAttackEffect(player1.x, player1.y - 100); } } // Soccer ball collection for (var i = soccerBalls.length - 1; i >= 0; i--) { var ball = soccerBalls[i]; if (ball.intersects(player1)) { player1.addPower(25); ball.collected = true; LK.getSound('powerup').play(); } else if (ball.intersects(player2)) { player2.addPower(25); ball.collected = true; LK.getSound('powerup').play(); } } } game.down = function (x, y, obj) { if (gameState !== 'playing') return; // Check Player 1 controls if (player1Controls.moveLeft.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p1MoveLeft = true; player1Controls.moveLeft.setPressed(true); } if (player1Controls.moveRight.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p1MoveRight = true; player1Controls.moveRight.setPressed(true); } if (player1Controls.jump.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p1Jump = true; player1Controls.jump.setPressed(true); player1.jump(); } if (player1Controls.attack.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p1Attack = true; player1Controls.attack.setPressed(true); player1.attack(); } // Check Player 2 controls if (player2Controls.moveLeft.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p2MoveLeft = true; player2Controls.moveLeft.setPressed(true); } if (player2Controls.moveRight.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p2MoveRight = true; player2Controls.moveRight.setPressed(true); } if (player2Controls.jump.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p2Jump = true; player2Controls.jump.setPressed(true); player2.jump(); } if (player2Controls.attack.intersects({ x: x, y: y, width: 1, height: 1 })) { controlStates.p2Attack = true; player2Controls.attack.setPressed(true); player2.attack(); } }; game.up = function (x, y, obj) { if (gameState !== 'playing') return; // Reset all control states and button appearances controlStates.p1MoveLeft = false; controlStates.p1MoveRight = false; controlStates.p1Jump = false; controlStates.p1Attack = false; controlStates.p2MoveLeft = false; controlStates.p2MoveRight = false; controlStates.p2Jump = false; controlStates.p2Attack = false; player1Controls.moveLeft.setPressed(false); player1Controls.moveRight.setPressed(false); player1Controls.jump.setPressed(false); player1Controls.attack.setPressed(false); player2Controls.moveLeft.setPressed(false); player2Controls.moveRight.setPressed(false); player2Controls.jump.setPressed(false); player2Controls.attack.setPressed(false); isHolding = false; holdTimer = 0; }; game.update = function () { if (gameState !== 'playing') return; // Handle continuous movement if (controlStates.p1MoveLeft) { player1.moveLeft(); } if (controlStates.p1MoveRight) { player1.moveRight(); } if (controlStates.p2MoveLeft) { player2.moveLeft(); } if (controlStates.p2MoveRight) { player2.moveRight(); } // Update players player1.update(); player2.update(); // Update UI player1HealthBar.updateHealth(player1.health, player1.maxHealth); player2HealthBar.updateHealth(player2.health, player2.maxHealth); powerFill1.scaleX = player1.power / 100 * 0.5; powerFill2.scaleX = -(player2.power / 100) * 0.5; // Spawn soccer balls ballSpawnTimer++; if (ballSpawnTimer > 300) { // Every 5 seconds spawnSoccerBall(); ballSpawnTimer = 0; } // Update soccer balls for (var i = soccerBalls.length - 1; i >= 0; i--) { var ball = soccerBalls[i]; ball.update(); if (ball.collected || ball.lifetime <= 0) { ball.destroy(); soccerBalls.splice(i, 1); } } // Update attack effects for (var j = attackEffects.length - 1; j >= 0; j--) { var effect = attackEffects[j]; effect.update(); if (effect.lifetime <= 0) { effect.destroy(); attackEffects.splice(j, 1); } } // Check collisions checkCollisions(); // Check win conditions if (player1.health <= 0) { gameState = 'gameover'; LK.setScore(2); // Player 2 wins LK.showGameOver(); } else if (player2.health <= 0) { gameState = 'gameover'; LK.setScore(1); // Player 1 wins LK.showYouWin(); } // Update hold timer for blocking if (isHolding) { holdTimer++; } };
===================================================================
--- original.js
+++ change.js
@@ -304,35 +304,37 @@
var holdTimer = 0;
var touchStartTime = 0;
// Control buttons - Player 1 (left side)
var player1Controls = {
- move: new ControlButton('↔', 170, LK.gui.height - 120),
+ moveLeft: new ControlButton('←', 120, LK.gui.height - 120),
+ moveRight: new ControlButton('→', 220, LK.gui.height - 120),
jump: new ControlButton('A', 120, LK.gui.height - 220),
attack: new ControlButton('B', 220, LK.gui.height - 220)
};
// Control buttons - Player 2 (right side)
var player2Controls = {
- move: new ControlButton('↔', LK.gui.width - 170, LK.gui.height - 120),
+ moveLeft: new ControlButton('←', LK.gui.width - 220, LK.gui.height - 120),
+ moveRight: new ControlButton('→', LK.gui.width - 120, LK.gui.height - 120),
jump: new ControlButton('A', LK.gui.width - 220, LK.gui.height - 220),
attack: new ControlButton('B', LK.gui.width - 120, LK.gui.height - 220)
};
// Add control buttons to GUI
-LK.gui.bottomLeft.addChild(player1Controls.move);
+LK.gui.bottomLeft.addChild(player1Controls.moveLeft);
+LK.gui.bottomLeft.addChild(player1Controls.moveRight);
LK.gui.bottomLeft.addChild(player1Controls.jump);
LK.gui.bottomLeft.addChild(player1Controls.attack);
-LK.gui.bottomRight.addChild(player2Controls.move);
+LK.gui.bottomRight.addChild(player2Controls.moveLeft);
+LK.gui.bottomRight.addChild(player2Controls.moveRight);
LK.gui.bottomRight.addChild(player2Controls.jump);
LK.gui.bottomRight.addChild(player2Controls.attack);
// Control states
var controlStates = {
- p1Move: false,
- p1MoveDirection: 0,
- // -1 for left, 1 for right
+ p1MoveLeft: false,
+ p1MoveRight: false,
p1Jump: false,
p1Attack: false,
- p2Move: false,
- p2MoveDirection: 0,
- // -1 for left, 1 for right
+ p2MoveLeft: false,
+ p2MoveRight: false,
p2Jump: false,
p2Attack: false
};
function spawnSoccerBall() {
@@ -396,20 +398,26 @@
}
game.down = function (x, y, obj) {
if (gameState !== 'playing') return;
// Check Player 1 controls
- if (player1Controls.move.intersects({
+ if (player1Controls.moveLeft.intersects({
x: x,
y: y,
width: 1,
height: 1
})) {
- controlStates.p1Move = true;
- // Determine direction based on touch position relative to button center
- var buttonCenterX = player1Controls.move.x;
- controlStates.p1MoveDirection = x < buttonCenterX ? -1 : 1;
- player1Controls.move.setPressed(true);
+ controlStates.p1MoveLeft = true;
+ player1Controls.moveLeft.setPressed(true);
}
+ if (player1Controls.moveRight.intersects({
+ x: x,
+ y: y,
+ width: 1,
+ height: 1
+ })) {
+ controlStates.p1MoveRight = true;
+ player1Controls.moveRight.setPressed(true);
+ }
if (player1Controls.jump.intersects({
x: x,
y: y,
width: 1,
@@ -429,20 +437,26 @@
player1Controls.attack.setPressed(true);
player1.attack();
}
// Check Player 2 controls
- if (player2Controls.move.intersects({
+ if (player2Controls.moveLeft.intersects({
x: x,
y: y,
width: 1,
height: 1
})) {
- controlStates.p2Move = true;
- // Determine direction based on touch position relative to button center
- var buttonCenterX = player2Controls.move.x;
- controlStates.p2MoveDirection = x < buttonCenterX ? -1 : 1;
- player2Controls.move.setPressed(true);
+ controlStates.p2MoveLeft = true;
+ player2Controls.moveLeft.setPressed(true);
}
+ if (player2Controls.moveRight.intersects({
+ x: x,
+ y: y,
+ width: 1,
+ height: 1
+ })) {
+ controlStates.p2MoveRight = true;
+ player2Controls.moveRight.setPressed(true);
+ }
if (player2Controls.jump.intersects({
x: x,
y: y,
width: 1,
@@ -465,42 +479,42 @@
};
game.up = function (x, y, obj) {
if (gameState !== 'playing') return;
// Reset all control states and button appearances
- controlStates.p1Move = false;
- controlStates.p1MoveDirection = 0;
+ controlStates.p1MoveLeft = false;
+ controlStates.p1MoveRight = false;
controlStates.p1Jump = false;
controlStates.p1Attack = false;
- controlStates.p2Move = false;
- controlStates.p2MoveDirection = 0;
+ controlStates.p2MoveLeft = false;
+ controlStates.p2MoveRight = false;
controlStates.p2Jump = false;
controlStates.p2Attack = false;
- player1Controls.move.setPressed(false);
+ player1Controls.moveLeft.setPressed(false);
+ player1Controls.moveRight.setPressed(false);
player1Controls.jump.setPressed(false);
player1Controls.attack.setPressed(false);
- player2Controls.move.setPressed(false);
+ player2Controls.moveLeft.setPressed(false);
+ player2Controls.moveRight.setPressed(false);
player2Controls.jump.setPressed(false);
player2Controls.attack.setPressed(false);
isHolding = false;
holdTimer = 0;
};
game.update = function () {
if (gameState !== 'playing') return;
// Handle continuous movement
- if (controlStates.p1Move) {
- if (controlStates.p1MoveDirection === -1) {
- player1.moveLeft();
- } else if (controlStates.p1MoveDirection === 1) {
- player1.moveRight();
- }
+ if (controlStates.p1MoveLeft) {
+ player1.moveLeft();
}
- if (controlStates.p2Move) {
- if (controlStates.p2MoveDirection === -1) {
- player2.moveLeft();
- } else if (controlStates.p2MoveDirection === 1) {
- player2.moveRight();
- }
+ if (controlStates.p1MoveRight) {
+ player1.moveRight();
}
+ if (controlStates.p2MoveLeft) {
+ player2.moveLeft();
+ }
+ if (controlStates.p2MoveRight) {
+ player2.moveRight();
+ }
// Update players
player1.update();
player2.update();
// Update UI
Un tipo con barba y pelo mediano que tenga una camiseta con rayas blancas y celestes. In-Game asset. High contrast. No shadows. 2d
Has a una persona igual a Cristiano Ronaldo. In-Game asset. 2d. High contrast. No shadows
Un balón normal. In-Game asset. 2d. High contrast. No shadows
Que sea redondo y que adentro tenga la letra a y que sea el fondo azul