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 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; 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.update = function () { if (self.attackCooldown > 0) self.attackCooldown--; if (self.specialCooldown > 0) self.specialCooldown--; }; 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('TAP: Attack | HOLD: Block | SWIPE: Special', { size: 40, fill: 0xFFFFFF }); instructText.anchor.set(0.5, 1); instructText.y = LK.gui.height - 50; LK.gui.bottom.addChild(instructText); // Touch controls var isHolding = false; var holdTimer = 0; var touchStartTime = 0; 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; isHolding = true; holdTimer = 0; touchStartTime = LK.ticks; // Determine which side was touched for player control if (x < 1024) { // Left side - Player 1 controls if (!player1.attack()) { player1.block(true); } } else { // Right side - Player 2 controls if (!player2.attack()) { player2.block(true); } } }; game.up = function (x, y, obj) { if (gameState !== 'playing') return; var touchDuration = LK.ticks - touchStartTime; // Stop blocking player1.block(false); player2.block(false); // Check for swipe (quick touch) if (touchDuration < 10) { if (x < 1024) { player1.specialAttack(); } else { player2.specialAttack(); } } isHolding = false; holdTimer = 0; }; game.update = function () { if (gameState !== 'playing') return; // 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
@@ -1,6 +1,396 @@
-/****
+/****
+* 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 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;
+ 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.update = function () {
+ if (self.attackCooldown > 0) self.attackCooldown--;
+ if (self.specialCooldown > 0) self.specialCooldown--;
+ };
+ 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: 0x000000
-});
\ No newline at end of file
+ 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('TAP: Attack | HOLD: Block | SWIPE: Special', {
+ size: 40,
+ fill: 0xFFFFFF
+});
+instructText.anchor.set(0.5, 1);
+instructText.y = LK.gui.height - 50;
+LK.gui.bottom.addChild(instructText);
+// Touch controls
+var isHolding = false;
+var holdTimer = 0;
+var touchStartTime = 0;
+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;
+ isHolding = true;
+ holdTimer = 0;
+ touchStartTime = LK.ticks;
+ // Determine which side was touched for player control
+ if (x < 1024) {
+ // Left side - Player 1 controls
+ if (!player1.attack()) {
+ player1.block(true);
+ }
+ } else {
+ // Right side - Player 2 controls
+ if (!player2.attack()) {
+ player2.block(true);
+ }
+ }
+};
+game.up = function (x, y, obj) {
+ if (gameState !== 'playing') return;
+ var touchDuration = LK.ticks - touchStartTime;
+ // Stop blocking
+ player1.block(false);
+ player2.block(false);
+ // Check for swipe (quick touch)
+ if (touchDuration < 10) {
+ if (x < 1024) {
+ player1.specialAttack();
+ } else {
+ player2.specialAttack();
+ }
+ }
+ isHolding = false;
+ holdTimer = 0;
+};
+game.update = function () {
+ if (gameState !== 'playing') return;
+ // 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++;
+ }
+};
\ No newline at end of file
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