User prompt
Make one sound play when attacking and another when using the skill
User prompt
Make Heal text below the player buttons
User prompt
Converts the Spare text to a bar
User prompt
Reduces the player's invulnerability seconds
User prompt
Make the enemy's life bar on the left and Spare text on the right
User prompt
Make the enemy's life bar on the left and Spare on the right and Spare is one bar
User prompt
Make the enemy's life bar use enemybar
User prompt
Fix enemy health bar being below buttons
User prompt
Make the enemy have a life bar and be below the buttons
User prompt
Move the enemy's life bar down the buttons
User prompt
Make the health bar and Spare be below
User prompt
Make spare a 100% bar and every time spare is used it fills 5%
User prompt
Make spear a 100% bar and every time you use Spear it fills up 5%
User prompt
Make the life of the enemy a bar and not cover the enemy
User prompt
Move everything that is covering the enemy
User prompt
Make the player's HP text appear on their bar
User prompt
Make the player's HP text on the bar black.
User prompt
Make the player's life a bar and be at the bottom with the buttons but without getting in the way
User prompt
Adds more difficult attack patterns
User prompt
Make it so that when the player attacks he receives 6 of TP
User prompt
Let them be a little further apart
User prompt
Order the buttons, first the attack button, then the ability button, then the healing button and finally the spare button.
User prompt
Adds an attack that consumes 50 TP but does 500 to 700 damage
User prompt
Make the TP cannot have more than one decimal place
User prompt
Make the TP only a decimal
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Player = Container.expand(function () { var self = Container.call(this); self.moveSpeed = 8; self.isMoving = false; self.targetX = 0; self.targetY = 0; var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.moveTo = function (x, y) { if (x < battleBoxLeft + 30) x = battleBoxLeft + 30; if (x > battleBoxRight - 30) x = battleBoxRight - 30; if (y < battleBoxTop + 30) y = battleBoxTop + 30; if (y > battleBoxBottom - 30) y = battleBoxBottom - 30; self.targetX = x; self.targetY = y; self.isMoving = true; }; self.update = function () { if (self.isMoving) { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < self.moveSpeed) { self.x = self.targetX; self.y = self.targetY; self.isMoving = false; } else { self.x += dx / distance * self.moveSpeed; self.y += dy / distance * self.moveSpeed; } } }; return self; }); var Projectile = Container.expand(function () { var self = Container.call(this); self.velocityX = 0; self.velocityY = 0; self.isActive = true; var projectileGraphics = self.attachAsset('projectile', { anchorX: 0.5, anchorY: 0.5 }); self.setVelocity = function (vx, vy) { self.velocityX = vx; self.velocityY = vy; }; self.update = function () { if (self.isActive) { self.x += self.velocityX; self.y += self.velocityY; // Remove if out of battle box bounds if (self.x < battleBoxLeft - 50 || self.x > battleBoxRight + 50 || self.y < battleBoxTop - 50 || self.y > battleBoxBottom + 50) { self.isActive = false; } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x111111 }); /**** * Game Code ****/ // Game state variables var gameState = 'attack'; // 'attack' or 'defense' var playerHealth = 100; var maxHealth = 100; var enemyHealth = 8000; var maxEnemyHealth = 8000; var projectiles = []; var defenseTimer = 0; var defenseDuration = 300; // 5 seconds at 60fps var spareCount = 0; var maxSpareCount = 15; var healCount = 0; var maxHealCount = 8; var isInvulnerable = false; var invulnerabilityDuration = 150; // 2.5 seconds at 60fps var playerTP = 0; var maxTP = 100; var narrowDodgeDistance = 80; // Distance threshold for narrow dodge // Battle box boundaries var battleBoxLeft = 1024 - 400; var battleBoxRight = 1024 + 400; var battleBoxTop = 1366 - 300; var battleBoxBottom = 1366 + 300; // Create battle box var battleBox = game.addChild(LK.getAsset('battleBox', { anchorX: 0.5, anchorY: 0.5 })); battleBox.x = 1024; battleBox.y = 1366; // Create player var player = game.addChild(new Player()); player.x = 1024; player.y = 1366; // Create TP hitbox visual var tpHitbox = game.addChild(LK.getAsset('tpHitbox', { anchorX: 0.5, anchorY: 0.5 })); tpHitbox.x = player.x; tpHitbox.y = player.y; tpHitbox.alpha = 0.3; // Create health bar background var healthBarBg = game.addChild(LK.getAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 })); healthBarBg.x = 1024; healthBarBg.y = 300; // Create health bar var healthBar = game.addChild(LK.getAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 })); healthBar.x = 1024; healthBar.y = 300; // Create enemy sprite var enemy = game.addChild(LK.getAsset('enemy', { anchorX: 0.5, anchorY: 0.5 })); enemy.x = 1024; enemy.y = 800; // Create attack button var attackButton = game.addChild(LK.getAsset('attackButton', { anchorX: 0.5, anchorY: 0.5 })); attackButton.x = 900; attackButton.y = 1800; // Create spare button var spareButton = game.addChild(LK.getAsset('spareButton', { anchorX: 0.5, anchorY: 0.5 })); spareButton.x = 1148; spareButton.y = 1800; // Create heal button var healButton = game.addChild(LK.getAsset('healButton', { anchorX: 0.5, anchorY: 0.5 })); healButton.x = 1024; healButton.y = 1700; // Create movement buttons var upButton = game.addChild(LK.getAsset('upButton', { anchorX: 0.5, anchorY: 0.5 })); upButton.x = 1024; upButton.y = 1850; var downButton = game.addChild(LK.getAsset('downButton', { anchorX: 0.5, anchorY: 0.5 })); downButton.x = 1024; downButton.y = 2150; var leftButton = game.addChild(LK.getAsset('leftButton', { anchorX: 0.5, anchorY: 0.5 })); leftButton.x = 850; leftButton.y = 2000; var rightButton = game.addChild(LK.getAsset('rightButton', { anchorX: 0.5, anchorY: 0.5 })); rightButton.x = 1198; rightButton.y = 2000; // Create UI text var phaseText = new Text2('ATTACK PHASE', { size: 80, fill: 0xFFFF00 }); phaseText.anchor.set(0.5, 0); phaseText.x = 1024; phaseText.y = 200; game.addChild(phaseText); var healthText = new Text2('HP: 100/100', { size: 50, fill: 0xFFFFFF }); healthText.anchor.set(0.5, 0); healthText.x = 1024; healthText.y = 350; game.addChild(healthText); // Create enemy health bar background var enemyHealthBarBg = game.addChild(LK.getAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 })); enemyHealthBarBg.x = 1024; enemyHealthBarBg.y = 650; // Create enemy health bar var enemyHealthBar = game.addChild(LK.getAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 })); enemyHealthBar.x = 1024; enemyHealthBar.y = 650; enemyHealthBar.tint = 0xff0000; var enemyHealthText = new Text2('Enemy HP: 100/100', { size: 50, fill: 0xFFFFFF }); enemyHealthText.anchor.set(0.5, 0); enemyHealthText.x = 1024; enemyHealthText.y = 700; game.addChild(enemyHealthText); var spareText = new Text2('Spare Progress: 0/15', { size: 50, fill: 0x00ff66 }); spareText.anchor.set(0.5, 0); spareText.x = 1024; spareText.y = 750; game.addChild(spareText); var healText = new Text2('Heals: 8/8', { size: 50, fill: 0x00ff00 }); healText.anchor.set(0.5, 0); healText.x = 1024; healText.y = 800; game.addChild(healText); // Create TP bar background var tpBarBg = game.addChild(LK.getAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 })); tpBarBg.x = 1024; tpBarBg.y = 400; // Create TP bar var tpBar = game.addChild(LK.getAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 })); tpBar.x = 1024; tpBar.y = 400; tpBar.tint = 0xffff00; var tpText = new Text2('TP: 0/100', { size: 50, fill: 0xffff00 }); tpText.anchor.set(0.5, 0); tpText.x = 1024; tpText.y = 450; game.addChild(tpText); // Button event handlers attackButton.down = function () { if (gameState === 'attack') { var damage = Math.floor(Math.random() * 101) + 100; // Random damage between 100-200 enemyHealth -= damage; updateEnemyHealthBar(); if (enemyHealth <= 0) { LK.showYouWin(); return; } startDefensePhase(); } }; spareButton.down = function () { if (gameState === 'attack') { spareCount++; updateSpareProgress(); if (spareCount >= maxSpareCount) { LK.showYouWin(); return; } startDefensePhase(); } }; healButton.down = function () { if (gameState === 'attack' && healCount < maxHealCount && playerHealth < maxHealth) { healCount++; playerHealth = Math.min(playerHealth + 50, maxHealth); updateHealthBar(); updateHealCount(); LK.getSound('heal').play(); LK.effects.flashObject(player, 0x00ff00, 300); startDefensePhase(); } }; upButton.down = function () { if (gameState === 'defense') { player.moveTo(player.x, player.y - 60); LK.getSound('dodge').play(); } }; downButton.down = function () { if (gameState === 'defense') { player.moveTo(player.x, player.y + 60); LK.getSound('dodge').play(); } }; leftButton.down = function () { if (gameState === 'defense') { player.moveTo(player.x - 60, player.y); LK.getSound('dodge').play(); } }; rightButton.down = function () { if (gameState === 'defense') { player.moveTo(player.x + 60, player.y); LK.getSound('dodge').play(); } }; function startDefensePhase() { gameState = 'defense'; defenseTimer = 0; phaseText.setText('DEFENSE PHASE'); phaseText.tint = 0xff0000; // Hide attack buttons, show movement buttons attackButton.visible = false; spareButton.visible = false; healButton.visible = false; upButton.visible = true; downButton.visible = true; leftButton.visible = true; rightButton.visible = true; } function startAttackPhase() { gameState = 'attack'; phaseText.setText('ATTACK PHASE'); phaseText.tint = 0xffff00; // Clear all projectiles for (var i = projectiles.length - 1; i >= 0; i--) { projectiles[i].destroy(); projectiles.splice(i, 1); } // Show attack buttons, hide movement buttons attackButton.visible = true; spareButton.visible = true; healButton.visible = true; upButton.visible = false; downButton.visible = false; leftButton.visible = false; rightButton.visible = false; } function spawnProjectile(x, y, vx, vy) { var projectile = new Projectile(); projectile.x = x; projectile.y = y; projectile.setVelocity(vx, vy); projectiles.push(projectile); game.addChild(projectile); } function updateProjectilePattern() { if (defenseTimer % 30 === 0) { // Spawn every 0.5 seconds var patternType = Math.floor(Math.random() * 5); if (patternType === 0) { // Horizontal sweep for (var i = 0; i < 3; i++) { spawnProjectile(battleBoxLeft - 30, battleBoxTop + 150 + i * 150, 4, 0); } } else if (patternType === 1) { // Vertical sweep for (var i = 0; i < 4; i++) { spawnProjectile(battleBoxLeft + 150 + i * 150, battleBoxTop - 30, 0, 3); } } else if (patternType === 2) { // Circular pattern from center var centerX = battleBoxLeft + 400; var centerY = battleBoxTop + 300; for (var i = 0; i < 8; i++) { var angle = i * Math.PI * 2 / 8; var vx = Math.cos(angle) * 3; var vy = Math.sin(angle) * 3; spawnProjectile(centerX, centerY, vx, vy); } } else if (patternType === 3) { // Cross pattern var centerX = battleBoxLeft + 400; var centerY = battleBoxTop + 300; spawnProjectile(centerX, centerY, 4, 0); spawnProjectile(centerX, centerY, -4, 0); spawnProjectile(centerX, centerY, 0, 4); spawnProjectile(centerX, centerY, 0, -4); spawnProjectile(centerX, centerY, 3, 3); spawnProjectile(centerX, centerY, -3, -3); spawnProjectile(centerX, centerY, 3, -3); spawnProjectile(centerX, centerY, -3, 3); } else { // Spiral pattern var centerX = battleBoxLeft + 400; var centerY = battleBoxTop + 300; for (var i = 0; i < 6; i++) { var angle = defenseTimer * 0.1 + i * Math.PI / 3; var vx = Math.cos(angle) * 2.5; var vy = Math.sin(angle) * 2.5; spawnProjectile(centerX, centerY, vx, vy); } } } } function updateHealthBar() { var healthPercent = playerHealth / maxHealth; healthBar.scaleX = healthPercent; healthBar.x = 1024 - 200 * (1 - healthPercent); healthText.setText('HP: ' + playerHealth + '/' + maxHealth); } function updateEnemyHealthBar() { var enemyHealthPercent = enemyHealth / maxEnemyHealth; enemyHealthBar.scaleX = enemyHealthPercent; enemyHealthBar.x = 1024 - 200 * (1 - enemyHealthPercent); enemyHealthText.setText('Enemy HP: ' + enemyHealth + '/' + maxEnemyHealth); } function updateSpareProgress() { spareText.setText('Spare Progress: ' + spareCount + '/' + maxSpareCount); } function updateHealCount() { var remaining = maxHealCount - healCount; healText.setText('Heals: ' + remaining + '/' + maxHealCount); if (remaining === 0) { healButton.alpha = 0.5; } } function updateTPBar() { var tpPercent = playerTP / maxTP; tpBar.scaleX = tpPercent; tpBar.x = 1024 - 200 * (1 - tpPercent); tpText.setText('TP: ' + playerTP + '/' + maxTP); } function checkNarrowDodge() { var hasNarrowDodge = false; for (var i = 0; i < projectiles.length; i++) { var projectile = projectiles[i]; if (projectile.isActive) { var dx = player.x - projectile.x; var dy = player.y - projectile.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance <= narrowDodgeDistance && distance > 30) { hasNarrowDodge = true; break; // Exit loop once we find one narrow dodge } } } if (hasNarrowDodge) { playerTP = Math.min(playerTP + 0.1, maxTP); updateTPBar(); LK.effects.flashObject(player, 0xffff00, 200); } } function checkCollisions() { for (var i = projectiles.length - 1; i >= 0; i--) { var projectile = projectiles[i]; if (projectile.isActive && player.intersects(projectile) && !isInvulnerable) { // Player hit playerHealth -= 10; LK.getSound('hit').play(); LK.effects.flashObject(player, 0xff0000, 200); // Start invulnerability isInvulnerable = true; player.alpha = 0.5; // Use tween to make player flash during invulnerability tween(player, { alpha: 1 }, { duration: 250, easing: tween.easeInOut, onFinish: function onFinish() { tween(player, { alpha: 0.5 }, { duration: 250, easing: tween.easeInOut }); } }); // Set timeout to end invulnerability LK.setTimeout(function () { isInvulnerable = false; tween.stop(player, { alpha: true }); player.alpha = 1; }, invulnerabilityDuration * 1000 / 60); // Convert frames to milliseconds // Remove projectile projectile.destroy(); projectiles.splice(i, 1); updateHealthBar(); if (playerHealth <= 0) { LK.showGameOver(); return; } } } } // Initialize UI state updateHealthBar(); updateEnemyHealthBar(); updateSpareProgress(); updateHealCount(); updateTPBar(); upButton.visible = false; downButton.visible = false; leftButton.visible = false; rightButton.visible = false; // Start battle music LK.playMusic('He2'); game.update = function () { // Update TP hitbox position to follow player tpHitbox.x = player.x; tpHitbox.y = player.y; // Show/hide TP hitbox based on game state tpHitbox.visible = gameState === 'defense'; if (gameState === 'defense') { defenseTimer++; // Update projectile patterns updateProjectilePattern(); // Check for narrow dodges checkNarrowDodge(); // Check for collisions checkCollisions(); // Remove inactive projectiles for (var i = projectiles.length - 1; i >= 0; i--) { if (!projectiles[i].isActive) { projectiles[i].destroy(); projectiles.splice(i, 1); } } // End defense phase if (defenseTimer >= defenseDuration) { startAttackPhase(); } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Player = Container.expand(function () {
var self = Container.call(this);
self.moveSpeed = 8;
self.isMoving = false;
self.targetX = 0;
self.targetY = 0;
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.moveTo = function (x, y) {
if (x < battleBoxLeft + 30) x = battleBoxLeft + 30;
if (x > battleBoxRight - 30) x = battleBoxRight - 30;
if (y < battleBoxTop + 30) y = battleBoxTop + 30;
if (y > battleBoxBottom - 30) y = battleBoxBottom - 30;
self.targetX = x;
self.targetY = y;
self.isMoving = true;
};
self.update = function () {
if (self.isMoving) {
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < self.moveSpeed) {
self.x = self.targetX;
self.y = self.targetY;
self.isMoving = false;
} else {
self.x += dx / distance * self.moveSpeed;
self.y += dy / distance * self.moveSpeed;
}
}
};
return self;
});
var Projectile = Container.expand(function () {
var self = Container.call(this);
self.velocityX = 0;
self.velocityY = 0;
self.isActive = true;
var projectileGraphics = self.attachAsset('projectile', {
anchorX: 0.5,
anchorY: 0.5
});
self.setVelocity = function (vx, vy) {
self.velocityX = vx;
self.velocityY = vy;
};
self.update = function () {
if (self.isActive) {
self.x += self.velocityX;
self.y += self.velocityY;
// Remove if out of battle box bounds
if (self.x < battleBoxLeft - 50 || self.x > battleBoxRight + 50 || self.y < battleBoxTop - 50 || self.y > battleBoxBottom + 50) {
self.isActive = false;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x111111
});
/****
* Game Code
****/
// Game state variables
var gameState = 'attack'; // 'attack' or 'defense'
var playerHealth = 100;
var maxHealth = 100;
var enemyHealth = 8000;
var maxEnemyHealth = 8000;
var projectiles = [];
var defenseTimer = 0;
var defenseDuration = 300; // 5 seconds at 60fps
var spareCount = 0;
var maxSpareCount = 15;
var healCount = 0;
var maxHealCount = 8;
var isInvulnerable = false;
var invulnerabilityDuration = 150; // 2.5 seconds at 60fps
var playerTP = 0;
var maxTP = 100;
var narrowDodgeDistance = 80; // Distance threshold for narrow dodge
// Battle box boundaries
var battleBoxLeft = 1024 - 400;
var battleBoxRight = 1024 + 400;
var battleBoxTop = 1366 - 300;
var battleBoxBottom = 1366 + 300;
// Create battle box
var battleBox = game.addChild(LK.getAsset('battleBox', {
anchorX: 0.5,
anchorY: 0.5
}));
battleBox.x = 1024;
battleBox.y = 1366;
// Create player
var player = game.addChild(new Player());
player.x = 1024;
player.y = 1366;
// Create TP hitbox visual
var tpHitbox = game.addChild(LK.getAsset('tpHitbox', {
anchorX: 0.5,
anchorY: 0.5
}));
tpHitbox.x = player.x;
tpHitbox.y = player.y;
tpHitbox.alpha = 0.3;
// Create health bar background
var healthBarBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0.5,
anchorY: 0.5
}));
healthBarBg.x = 1024;
healthBarBg.y = 300;
// Create health bar
var healthBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5
}));
healthBar.x = 1024;
healthBar.y = 300;
// Create enemy sprite
var enemy = game.addChild(LK.getAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
}));
enemy.x = 1024;
enemy.y = 800;
// Create attack button
var attackButton = game.addChild(LK.getAsset('attackButton', {
anchorX: 0.5,
anchorY: 0.5
}));
attackButton.x = 900;
attackButton.y = 1800;
// Create spare button
var spareButton = game.addChild(LK.getAsset('spareButton', {
anchorX: 0.5,
anchorY: 0.5
}));
spareButton.x = 1148;
spareButton.y = 1800;
// Create heal button
var healButton = game.addChild(LK.getAsset('healButton', {
anchorX: 0.5,
anchorY: 0.5
}));
healButton.x = 1024;
healButton.y = 1700;
// Create movement buttons
var upButton = game.addChild(LK.getAsset('upButton', {
anchorX: 0.5,
anchorY: 0.5
}));
upButton.x = 1024;
upButton.y = 1850;
var downButton = game.addChild(LK.getAsset('downButton', {
anchorX: 0.5,
anchorY: 0.5
}));
downButton.x = 1024;
downButton.y = 2150;
var leftButton = game.addChild(LK.getAsset('leftButton', {
anchorX: 0.5,
anchorY: 0.5
}));
leftButton.x = 850;
leftButton.y = 2000;
var rightButton = game.addChild(LK.getAsset('rightButton', {
anchorX: 0.5,
anchorY: 0.5
}));
rightButton.x = 1198;
rightButton.y = 2000;
// Create UI text
var phaseText = new Text2('ATTACK PHASE', {
size: 80,
fill: 0xFFFF00
});
phaseText.anchor.set(0.5, 0);
phaseText.x = 1024;
phaseText.y = 200;
game.addChild(phaseText);
var healthText = new Text2('HP: 100/100', {
size: 50,
fill: 0xFFFFFF
});
healthText.anchor.set(0.5, 0);
healthText.x = 1024;
healthText.y = 350;
game.addChild(healthText);
// Create enemy health bar background
var enemyHealthBarBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0.5,
anchorY: 0.5
}));
enemyHealthBarBg.x = 1024;
enemyHealthBarBg.y = 650;
// Create enemy health bar
var enemyHealthBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5
}));
enemyHealthBar.x = 1024;
enemyHealthBar.y = 650;
enemyHealthBar.tint = 0xff0000;
var enemyHealthText = new Text2('Enemy HP: 100/100', {
size: 50,
fill: 0xFFFFFF
});
enemyHealthText.anchor.set(0.5, 0);
enemyHealthText.x = 1024;
enemyHealthText.y = 700;
game.addChild(enemyHealthText);
var spareText = new Text2('Spare Progress: 0/15', {
size: 50,
fill: 0x00ff66
});
spareText.anchor.set(0.5, 0);
spareText.x = 1024;
spareText.y = 750;
game.addChild(spareText);
var healText = new Text2('Heals: 8/8', {
size: 50,
fill: 0x00ff00
});
healText.anchor.set(0.5, 0);
healText.x = 1024;
healText.y = 800;
game.addChild(healText);
// Create TP bar background
var tpBarBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0.5,
anchorY: 0.5
}));
tpBarBg.x = 1024;
tpBarBg.y = 400;
// Create TP bar
var tpBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0.5,
anchorY: 0.5
}));
tpBar.x = 1024;
tpBar.y = 400;
tpBar.tint = 0xffff00;
var tpText = new Text2('TP: 0/100', {
size: 50,
fill: 0xffff00
});
tpText.anchor.set(0.5, 0);
tpText.x = 1024;
tpText.y = 450;
game.addChild(tpText);
// Button event handlers
attackButton.down = function () {
if (gameState === 'attack') {
var damage = Math.floor(Math.random() * 101) + 100; // Random damage between 100-200
enemyHealth -= damage;
updateEnemyHealthBar();
if (enemyHealth <= 0) {
LK.showYouWin();
return;
}
startDefensePhase();
}
};
spareButton.down = function () {
if (gameState === 'attack') {
spareCount++;
updateSpareProgress();
if (spareCount >= maxSpareCount) {
LK.showYouWin();
return;
}
startDefensePhase();
}
};
healButton.down = function () {
if (gameState === 'attack' && healCount < maxHealCount && playerHealth < maxHealth) {
healCount++;
playerHealth = Math.min(playerHealth + 50, maxHealth);
updateHealthBar();
updateHealCount();
LK.getSound('heal').play();
LK.effects.flashObject(player, 0x00ff00, 300);
startDefensePhase();
}
};
upButton.down = function () {
if (gameState === 'defense') {
player.moveTo(player.x, player.y - 60);
LK.getSound('dodge').play();
}
};
downButton.down = function () {
if (gameState === 'defense') {
player.moveTo(player.x, player.y + 60);
LK.getSound('dodge').play();
}
};
leftButton.down = function () {
if (gameState === 'defense') {
player.moveTo(player.x - 60, player.y);
LK.getSound('dodge').play();
}
};
rightButton.down = function () {
if (gameState === 'defense') {
player.moveTo(player.x + 60, player.y);
LK.getSound('dodge').play();
}
};
function startDefensePhase() {
gameState = 'defense';
defenseTimer = 0;
phaseText.setText('DEFENSE PHASE');
phaseText.tint = 0xff0000;
// Hide attack buttons, show movement buttons
attackButton.visible = false;
spareButton.visible = false;
healButton.visible = false;
upButton.visible = true;
downButton.visible = true;
leftButton.visible = true;
rightButton.visible = true;
}
function startAttackPhase() {
gameState = 'attack';
phaseText.setText('ATTACK PHASE');
phaseText.tint = 0xffff00;
// Clear all projectiles
for (var i = projectiles.length - 1; i >= 0; i--) {
projectiles[i].destroy();
projectiles.splice(i, 1);
}
// Show attack buttons, hide movement buttons
attackButton.visible = true;
spareButton.visible = true;
healButton.visible = true;
upButton.visible = false;
downButton.visible = false;
leftButton.visible = false;
rightButton.visible = false;
}
function spawnProjectile(x, y, vx, vy) {
var projectile = new Projectile();
projectile.x = x;
projectile.y = y;
projectile.setVelocity(vx, vy);
projectiles.push(projectile);
game.addChild(projectile);
}
function updateProjectilePattern() {
if (defenseTimer % 30 === 0) {
// Spawn every 0.5 seconds
var patternType = Math.floor(Math.random() * 5);
if (patternType === 0) {
// Horizontal sweep
for (var i = 0; i < 3; i++) {
spawnProjectile(battleBoxLeft - 30, battleBoxTop + 150 + i * 150, 4, 0);
}
} else if (patternType === 1) {
// Vertical sweep
for (var i = 0; i < 4; i++) {
spawnProjectile(battleBoxLeft + 150 + i * 150, battleBoxTop - 30, 0, 3);
}
} else if (patternType === 2) {
// Circular pattern from center
var centerX = battleBoxLeft + 400;
var centerY = battleBoxTop + 300;
for (var i = 0; i < 8; i++) {
var angle = i * Math.PI * 2 / 8;
var vx = Math.cos(angle) * 3;
var vy = Math.sin(angle) * 3;
spawnProjectile(centerX, centerY, vx, vy);
}
} else if (patternType === 3) {
// Cross pattern
var centerX = battleBoxLeft + 400;
var centerY = battleBoxTop + 300;
spawnProjectile(centerX, centerY, 4, 0);
spawnProjectile(centerX, centerY, -4, 0);
spawnProjectile(centerX, centerY, 0, 4);
spawnProjectile(centerX, centerY, 0, -4);
spawnProjectile(centerX, centerY, 3, 3);
spawnProjectile(centerX, centerY, -3, -3);
spawnProjectile(centerX, centerY, 3, -3);
spawnProjectile(centerX, centerY, -3, 3);
} else {
// Spiral pattern
var centerX = battleBoxLeft + 400;
var centerY = battleBoxTop + 300;
for (var i = 0; i < 6; i++) {
var angle = defenseTimer * 0.1 + i * Math.PI / 3;
var vx = Math.cos(angle) * 2.5;
var vy = Math.sin(angle) * 2.5;
spawnProjectile(centerX, centerY, vx, vy);
}
}
}
}
function updateHealthBar() {
var healthPercent = playerHealth / maxHealth;
healthBar.scaleX = healthPercent;
healthBar.x = 1024 - 200 * (1 - healthPercent);
healthText.setText('HP: ' + playerHealth + '/' + maxHealth);
}
function updateEnemyHealthBar() {
var enemyHealthPercent = enemyHealth / maxEnemyHealth;
enemyHealthBar.scaleX = enemyHealthPercent;
enemyHealthBar.x = 1024 - 200 * (1 - enemyHealthPercent);
enemyHealthText.setText('Enemy HP: ' + enemyHealth + '/' + maxEnemyHealth);
}
function updateSpareProgress() {
spareText.setText('Spare Progress: ' + spareCount + '/' + maxSpareCount);
}
function updateHealCount() {
var remaining = maxHealCount - healCount;
healText.setText('Heals: ' + remaining + '/' + maxHealCount);
if (remaining === 0) {
healButton.alpha = 0.5;
}
}
function updateTPBar() {
var tpPercent = playerTP / maxTP;
tpBar.scaleX = tpPercent;
tpBar.x = 1024 - 200 * (1 - tpPercent);
tpText.setText('TP: ' + playerTP + '/' + maxTP);
}
function checkNarrowDodge() {
var hasNarrowDodge = false;
for (var i = 0; i < projectiles.length; i++) {
var projectile = projectiles[i];
if (projectile.isActive) {
var dx = player.x - projectile.x;
var dy = player.y - projectile.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance <= narrowDodgeDistance && distance > 30) {
hasNarrowDodge = true;
break; // Exit loop once we find one narrow dodge
}
}
}
if (hasNarrowDodge) {
playerTP = Math.min(playerTP + 0.1, maxTP);
updateTPBar();
LK.effects.flashObject(player, 0xffff00, 200);
}
}
function checkCollisions() {
for (var i = projectiles.length - 1; i >= 0; i--) {
var projectile = projectiles[i];
if (projectile.isActive && player.intersects(projectile) && !isInvulnerable) {
// Player hit
playerHealth -= 10;
LK.getSound('hit').play();
LK.effects.flashObject(player, 0xff0000, 200);
// Start invulnerability
isInvulnerable = true;
player.alpha = 0.5;
// Use tween to make player flash during invulnerability
tween(player, {
alpha: 1
}, {
duration: 250,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(player, {
alpha: 0.5
}, {
duration: 250,
easing: tween.easeInOut
});
}
});
// Set timeout to end invulnerability
LK.setTimeout(function () {
isInvulnerable = false;
tween.stop(player, {
alpha: true
});
player.alpha = 1;
}, invulnerabilityDuration * 1000 / 60); // Convert frames to milliseconds
// Remove projectile
projectile.destroy();
projectiles.splice(i, 1);
updateHealthBar();
if (playerHealth <= 0) {
LK.showGameOver();
return;
}
}
}
}
// Initialize UI state
updateHealthBar();
updateEnemyHealthBar();
updateSpareProgress();
updateHealCount();
updateTPBar();
upButton.visible = false;
downButton.visible = false;
leftButton.visible = false;
rightButton.visible = false;
// Start battle music
LK.playMusic('He2');
game.update = function () {
// Update TP hitbox position to follow player
tpHitbox.x = player.x;
tpHitbox.y = player.y;
// Show/hide TP hitbox based on game state
tpHitbox.visible = gameState === 'defense';
if (gameState === 'defense') {
defenseTimer++;
// Update projectile patterns
updateProjectilePattern();
// Check for narrow dodges
checkNarrowDodge();
// Check for collisions
checkCollisions();
// Remove inactive projectiles
for (var i = projectiles.length - 1; i >= 0; i--) {
if (!projectiles[i].isActive) {
projectiles[i].destroy();
projectiles.splice(i, 1);
}
}
// End defense phase
if (defenseTimer >= defenseDuration) {
startAttackPhase();
}
}
};
Appearance: An advanced and dramatically redesigned robotic version of Mettaton. It has futuristic armor, energy wings, and a stylized design reminiscent of an anime mecha. He have a heels, 2d pixel art
Red heart pixel art. In-Game asset. 2d. High contrast. No shadows
Black button with an orange outline that says "attack" and has a sword icon, pixel art. In-Game asset. 2d. High contrast. No shadows
Just a square border white no details. In-Game asset. 2d. High contrast. No shadows
Black button with an orange outline that says "Item" and has a Bag icon, pixel art. In-Game asset. 2d. High contrast. No shadows
Black button with an orange outline that says "Spare" and has a X icon, pixel art. In-Game asset. 2d. High contrast. No shadows
Black button with an orange outline that says "Spell" and has a fire icon, pixel art. In-Game asset. 2d. High contrast. No shadows
Energy ball. In-Game asset. 2d. High contrast. No shadows