User prompt
As los botones más grandes y ponlos en la esquina contraria
User prompt
As que el jugador tenga botones para moverse
User prompt
As que en la pelea contra el boos el jugador tenga que esquiva cañones que le van disparando a el jugador pero lo cañones también le disparan al boos y le sacan 100 de vida al boos y al jugador le sacan 10 de vida ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
As que el free for allá te de 2 puntos
User prompt
As que cuando llegue el momento de pelear contra el boos la opción de todos contra todos y 1 vs 1 desaparezcan y que el jugador este obligado a pelear contra el boos
User prompt
As que cada que recolectes los puntos que tengas que recolectar para pasar a la siguiente clase tengas que matar a un jefe final que tendrá mejores armas y mucha más salud. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
As que el juego no se guarde más
User prompt
As que el jugador pueda bloquear ataques
User prompt
As que los bots cuando estén muy lastimado puedan correr a una esquina y curarse y que el jugador también pueda y as que los bots se puedan rendir cuando tenga poca vida pero solo ay un 20% de probabilidad de que se rinda y el jugador también se pueda rendir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Medieval Beatdown
Initial prompt
As un juego donde tengas que pelear pará subir de clases en cada clase tendrás mejores armas el juego estará basado en la era medieval abra Dos tipos de modos modo 1 vs 1 y modo todos contra todos en el modo 1 vs 1 estará el jugador peleando contra un bot y en el modo todos contra todos estara el jugador y 3 bots peleando mutuamente el juego se llamará medieval beatles (en la clase uno el jugador y los bots solo tendrán sus manos pará pelear ose a puño limpio y en la clase 2 ya tendrán armas)(abran 5 clases mientras más alta sea la clase mejor arma tendrá el jugador y los bots)
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Fighter = Container.expand(function (isPlayer, classLevel) {
var self = Container.call(this);
self.isPlayer = isPlayer || false;
self.classLevel = classLevel || 1;
self.maxHealth = 100;
self.health = self.maxHealth;
self.moveSpeed = 3;
self.aiTimer = 0;
self.lastAttackTime = 0;
self.isHealing = false;
self.healTimer = 0;
self.hasSurrendered = false;
self.healingPosition = null;
self.isBlocking = false;
self.blockTimer = 0;
self.lastBlockTime = 0;
// Create fighter graphics
var assetName = self.isPlayer ? 'player_class' + self.classLevel : 'ai_class' + self.classLevel;
var fighterGraphics = self.attachAsset(assetName, {
anchorX: 0.5,
anchorY: 0.5
});
// Create weapon based on class
var weaponTypes = ['fist', 'sword', 'axe', 'mace', 'halberd'];
var damages = [10, 15, 20, 25, 30];
var ranges = [50, 70, 60, 55, 90];
self.weapon = self.addChild(new Weapon(weaponTypes[self.classLevel - 1], damages[self.classLevel - 1], ranges[self.classLevel - 1]));
self.weapon.x = 40;
// Create health bar
self.healthBarBg = self.attachAsset('health_bar_bg', {
anchorX: 0.5,
anchorY: 0.5,
y: -80
});
self.healthBarFill = self.attachAsset('health_bar_fill', {
anchorX: 0,
anchorY: 0.5,
x: -100,
y: -80
});
self.takeDamage = function (damage) {
var actualDamage = damage;
// Check if blocking
if (self.isBlocking && self.blockTimer < 30) {
// Block only works for first 30 frames (0.5 seconds)
actualDamage = Math.floor(damage * 0.3); // Block reduces damage by 70%
// Visual feedback for successful block
LK.effects.flashObject(fighterGraphics, 0x00ff00, 200);
// Stop blocking after successful block
self.stopBlocking();
} else {
// Flash red when taking full damage
LK.effects.flashObject(fighterGraphics, 0xff0000, 300);
}
self.health -= actualDamage;
if (self.health < 0) self.health = 0;
// Update health bar
var healthPercent = self.health / self.maxHealth;
self.healthBarFill.width = 200 * healthPercent;
// Stop healing if taking damage
if (self.isHealing) {
self.stopHealing();
}
return self.health <= 0;
};
self.startHealing = function () {
if (self.isHealing || self.isDead() || self.hasSurrendered) return false;
// Find nearest corner for healing
var corners = [{
x: 150,
y: 250
},
// top-left
{
x: 1898,
y: 250
},
// top-right
{
x: 150,
y: 2482
},
// bottom-left
{
x: 1898,
y: 2482
} // bottom-right
];
var nearestCorner = corners[0];
var minDistance = Infinity;
for (var i = 0; i < corners.length; i++) {
var distance = Math.sqrt(Math.pow(corners[i].x - self.x, 2) + Math.pow(corners[i].y - self.y, 2));
if (distance < minDistance) {
minDistance = distance;
nearestCorner = corners[i];
}
}
self.healingPosition = nearestCorner;
self.isHealing = true;
self.healTimer = 0;
// Visual feedback - green tint while healing
tween(fighterGraphics, {
tint: 0x00ff00
}, {
duration: 300
});
return true;
};
self.stopHealing = function () {
if (!self.isHealing) return;
self.isHealing = false;
self.healTimer = 0;
self.healingPosition = null;
// Remove green tint
tween(fighterGraphics, {
tint: 0xffffff
}, {
duration: 300
});
};
self.startBlocking = function () {
if (self.isDead() || self.hasSurrendered || self.isHealing) return false;
if (LK.ticks - self.lastBlockTime < 120) return false; // 2 second cooldown between blocks
self.isBlocking = true;
self.blockTimer = 0;
self.lastBlockTime = LK.ticks;
// Visual feedback - blue tint while blocking
tween(fighterGraphics, {
tint: 0x0099ff,
scaleX: 0.9,
scaleY: 1.1
}, {
duration: 200
});
return true;
};
self.stopBlocking = function () {
if (!self.isBlocking) return;
self.isBlocking = false;
self.blockTimer = 0;
// Remove blue tint and restore normal scale
tween(fighterGraphics, {
tint: 0xffffff,
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
};
self.surrender = function () {
if (self.hasSurrendered || self.isDead()) return false;
self.hasSurrendered = true;
self.stopHealing();
// Visual feedback - gray tint when surrendered
tween(fighterGraphics, {
tint: 0x666666,
alpha: 0.7
}, {
duration: 500
});
return true;
};
self.isDead = function () {
return self.health <= 0 || self.hasSurrendered;
};
self.attackTarget = function (target) {
if (!target || target.isDead()) return false;
var distance = Math.sqrt(Math.pow(target.x - self.x, 2) + Math.pow(target.y - self.y, 2));
if (distance <= self.weapon.range && self.weapon.attack()) {
var isDead = target.takeDamage(self.weapon.damage);
// Play sound
if (self.weapon.weaponType === 'fist') {
LK.getSound('punch').play();
} else {
LK.getSound('sword_hit').play();
}
return isDead;
}
return false;
};
self.moveTowards = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.moveSpeed;
self.y += dy / distance * self.moveSpeed;
}
};
self.aiUpdate = function (targets) {
if (self.isDead()) return;
self.aiTimer++;
// Check for surrender (20% chance when health is low)
if (self.health <= 30 && !self.hasSurrendered && Math.random() < 0.002) {
// 0.002 per frame ≈ 20% chance over time
self.surrender();
return;
}
// Check if should start healing (when health is below 40% and not currently healing)
if (self.health <= 40 && !self.isHealing && !self.hasSurrendered) {
// Find if any enemies are nearby before healing
var hasNearbyEnemies = false;
for (var i = 0; i < targets.length; i++) {
if (targets[i] !== self && !targets[i].isDead()) {
var distance = Math.sqrt(Math.pow(targets[i].x - self.x, 2) + Math.pow(targets[i].y - self.y, 2));
if (distance < 200) {
// Enemy within 200 pixels
hasNearbyEnemies = true;
break;
}
}
}
// Only start healing if no enemies nearby or health is critically low
if (!hasNearbyEnemies || self.health <= 20) {
self.startHealing();
}
}
// If healing, move to healing position
if (self.isHealing && self.healingPosition) {
var distanceToHealPos = Math.sqrt(Math.pow(self.healingPosition.x - self.x, 2) + Math.pow(self.healingPosition.y - self.y, 2));
if (distanceToHealPos > 10) {
self.moveTowards(self.healingPosition.x, self.healingPosition.y);
} else {
// At healing position, start healing
self.healTimer++;
if (self.healTimer >= 60) {
// Heal every 60 frames (1 second)
self.health = Math.min(self.maxHealth, self.health + 5);
// Update health bar
var healthPercent = self.health / self.maxHealth;
self.healthBarFill.width = 200 * healthPercent;
self.healTimer = 0;
// Stop healing when at full health or health above 70%
if (self.health >= self.maxHealth * 0.7) {
self.stopHealing();
}
}
}
return; // Don't do combat actions while healing
}
// Find nearest living target
var nearestTarget = null;
var nearestDistance = Infinity;
for (var i = 0; i < targets.length; i++) {
if (targets[i] !== self && !targets[i].isDead()) {
var distance = Math.sqrt(Math.pow(targets[i].x - self.x, 2) + Math.pow(targets[i].y - self.y, 2));
if (distance < nearestDistance) {
nearestDistance = distance;
nearestTarget = targets[i];
}
}
}
if (nearestTarget) {
// Move towards target if too far
if (nearestDistance > self.weapon.range * 0.8) {
self.moveTowards(nearestTarget.x, nearestTarget.y);
}
// Attack if in range and cooldown is ready
if (nearestDistance <= self.weapon.range && self.aiTimer % 45 === 0) {
self.attackTarget(nearestTarget);
}
}
};
self.update = function () {
// Keep within game bounds
if (self.x < 100) self.x = 100;
if (self.x > 1948) self.x = 1948;
if (self.y < 200) self.y = 200;
if (self.y > 2532) self.y = 2532;
// Update blocking timer
if (self.isBlocking) {
self.blockTimer++;
// Auto-stop blocking after 30 frames (0.5 seconds)
if (self.blockTimer >= 30) {
self.stopBlocking();
}
}
};
return self;
});
var MenuButton = Container.expand(function (text, onClick) {
var self = Container.call(this);
var buttonBg = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 40,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.down = function (x, y, obj) {
tween(buttonBg, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100
});
if (onClick) onClick();
};
self.up = function (x, y, obj) {
tween(buttonBg, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
};
return self;
});
var Weapon = Container.expand(function (weaponType, damage, range) {
var self = Container.call(this);
self.weaponType = weaponType || 'fist';
self.damage = damage || 10;
self.range = range || 50;
self.cooldown = 0;
var weaponGraphics = self.attachAsset(self.weaponType, {
anchorX: 0.5,
anchorY: 0.5
});
self.canAttack = function () {
return self.cooldown <= 0;
};
self.attack = function () {
if (self.canAttack()) {
self.cooldown = 30; // 30 frames cooldown
tween(weaponGraphics, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 100
});
tween(weaponGraphics, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
return true;
}
return false;
};
self.update = function () {
if (self.cooldown > 0) {
self.cooldown--;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Game state
// Player and AI character assets for different classes
// Weapon assets
// UI elements
// Sounds
var gameState = 'menu'; // 'menu', 'battle', 'victory', 'defeat'
var battleMode = 'duel'; // 'duel' or 'freeforall'
var playerClass = 1;
var playerWins = 0;
// UI elements
var titleText = new Text2('Medieval Beatdown', {
size: 80,
fill: 0xECF0F1
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 400;
game.addChild(titleText);
var classText = new Text2('Class ' + playerClass + ' Fighter', {
size: 50,
fill: 0xF39C12
});
classText.anchor.set(0.5, 0.5);
classText.x = 1024;
classText.y = 500;
game.addChild(classText);
var winsText = new Text2('Wins: ' + playerWins, {
size: 40,
fill: 0x95A5A6
});
winsText.anchor.set(0.5, 0.5);
winsText.x = 1024;
winsText.y = 550;
game.addChild(winsText);
var duelButton = game.addChild(new MenuButton('1v1 Duel', function () {
startBattle('duel');
}));
duelButton.x = 1024;
duelButton.y = 700;
var freeForAllButton = game.addChild(new MenuButton('Free For All', function () {
startBattle('freeforall');
}));
freeForAllButton.x = 1024;
freeForAllButton.y = 820;
// Battle variables
var fighters = [];
var player = null;
var dragTarget = null;
var battleTimer = 0;
// Battle result text
var resultText = new Text2('', {
size: 60,
fill: 0xFFFFFF
});
resultText.anchor.set(0.5, 0.5);
resultText.x = 1024;
resultText.y = 1366;
resultText.visible = false;
game.addChild(resultText);
var continueButton = game.addChild(new MenuButton('Continue', function () {
returnToMenu();
}));
continueButton.x = 1024;
continueButton.y = 1500;
continueButton.visible = false;
var controlsText = new Text2('Tap corners to heal • Tap center top to surrender • Tap center bottom to block', {
size: 28,
fill: 0xBDC3C7
});
controlsText.anchor.set(0.5, 0.5);
controlsText.x = 1024;
controlsText.y = 150;
controlsText.visible = false;
game.addChild(controlsText);
function startBattle(mode) {
gameState = 'battle';
battleMode = mode;
battleTimer = 0;
// Hide menu elements
titleText.visible = false;
classText.visible = false;
winsText.visible = false;
duelButton.visible = false;
freeForAllButton.visible = false;
resultText.visible = false;
continueButton.visible = false;
controlsText.visible = true;
// Clear previous fighters
for (var i = 0; i < fighters.length; i++) {
fighters[i].destroy();
}
fighters = [];
// Create player
player = game.addChild(new Fighter(true, playerClass));
player.x = 300;
player.y = 1366;
fighters.push(player);
// Create AI opponents
if (mode === 'duel') {
var enemy = game.addChild(new Fighter(false, playerClass));
enemy.x = 1700;
enemy.y = 1366;
fighters.push(enemy);
} else {
// Free for all - 3 AI opponents
for (var i = 0; i < 3; i++) {
var enemy = game.addChild(new Fighter(false, playerClass));
enemy.x = 1200 + i * 200;
enemy.y = 800 + i * 200;
fighters.push(enemy);
}
}
}
function checkBattleEnd() {
var aliveFighters = [];
var playerAlive = false;
for (var i = 0; i < fighters.length; i++) {
if (!fighters[i].isDead()) {
aliveFighters.push(fighters[i]);
if (fighters[i].isPlayer) {
playerAlive = true;
}
}
}
if (aliveFighters.length <= 1) {
if (playerAlive) {
// Player wins
playerWins++;
// Check for class advancement
var winsNeeded = playerClass * 3; // Need 3, 6, 9, 12, 15 wins for each class
if (playerWins >= winsNeeded && playerClass < 5) {
playerClass++;
resultText.setText('Victory! Advanced to Class ' + playerClass + '!');
} else {
resultText.setText('Victory! Wins: ' + playerWins);
}
LK.getSound('victory').play();
} else {
// Player loses
resultText.setText('Defeat! Try again!');
LK.getSound('defeat').play();
}
gameState = 'battleEnd';
resultText.visible = true;
continueButton.visible = true;
LK.setTimeout(function () {
// Auto return to menu after 5 seconds
if (gameState === 'battleEnd') {
returnToMenu();
}
}, 5000);
}
}
function returnToMenu() {
gameState = 'menu';
// Update UI text
classText.setText('Class ' + playerClass + ' Fighter');
winsText.setText('Wins: ' + playerWins);
// Show menu elements
titleText.visible = true;
classText.visible = true;
winsText.visible = true;
duelButton.visible = true;
freeForAllButton.visible = true;
resultText.visible = false;
continueButton.visible = false;
controlsText.visible = false;
// Clear fighters
for (var i = 0; i < fighters.length; i++) {
fighters[i].destroy();
}
fighters = [];
player = null;
dragTarget = null;
}
// Touch controls
game.down = function (x, y, obj) {
if (gameState === 'battle' && player && !player.isDead()) {
// Check for healing - double tap in corners
if (x < 200 && y < 400 || x > 1848 && y < 400 || x < 200 && y > 2332 || x > 1848 && y > 2332) {
if (!player.isHealing) {
player.startHealing();
} else {
player.stopHealing();
}
return;
}
// Check for surrender - double tap in center top area
if (x > 924 && x < 1124 && y > 100 && y < 300) {
if (!player.hasSurrendered) {
player.surrender();
}
return;
}
// Check for blocking - tap in center bottom area
if (x > 924 && x < 1124 && y > 2432 && y < 2632) {
if (!player.isBlocking) {
player.startBlocking();
}
return;
}
dragTarget = player;
// Check for attack - if touching near an enemy, attack instead of move
var attackRange = player.weapon.range + 50;
for (var i = 0; i < fighters.length; i++) {
var fighter = fighters[i];
if (fighter !== player && !fighter.isDead()) {
var distance = Math.sqrt(Math.pow(fighter.x - x, 2) + Math.pow(fighter.y - y, 2));
if (distance <= attackRange) {
player.attackTarget(fighter);
dragTarget = null;
return;
}
}
}
}
};
game.move = function (x, y, obj) {
if (gameState === 'battle' && dragTarget && !dragTarget.isDead()) {
dragTarget.moveTowards(x, y);
}
};
game.up = function (x, y, obj) {
dragTarget = null;
};
game.update = function () {
if (gameState === 'battle') {
battleTimer++;
// Update all fighters
for (var i = 0; i < fighters.length; i++) {
var fighter = fighters[i];
if (!fighter.isDead()) {
if (!fighter.isPlayer) {
fighter.aiUpdate(fighters);
}
}
}
// Check for battle end
checkBattleEnd();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,9 +1,8 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
-var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
@@ -374,10 +373,10 @@
// UI elements
// Sounds
var gameState = 'menu'; // 'menu', 'battle', 'victory', 'defeat'
var battleMode = 'duel'; // 'duel' or 'freeforall'
-var playerClass = storage.playerClass || 1;
-var playerWins = storage.playerWins || 0;
+var playerClass = 1;
+var playerWins = 0;
// UI elements
var titleText = new Text2('Medieval Beatdown', {
size: 80,
fill: 0xECF0F1
@@ -495,14 +494,12 @@
if (aliveFighters.length <= 1) {
if (playerAlive) {
// Player wins
playerWins++;
- storage.playerWins = playerWins;
// Check for class advancement
var winsNeeded = playerClass * 3; // Need 3, 6, 9, 12, 15 wins for each class
if (playerWins >= winsNeeded && playerClass < 5) {
playerClass++;
- storage.playerClass = playerClass;
resultText.setText('Victory! Advanced to Class ' + playerClass + '!');
} else {
resultText.setText('Victory! Wins: ' + playerWins);
}