Here's a nostalgic Pokémon battle UI using HTML, CSS, and JavaScript. It includes basic battle mechanics, animations, and sound effects:
<!DOCTYPE html>
<html>
<head>
<title>Pokémon Battle</title>
<style>
body {
background: #333;
font-family: 'Press Start 2P', monospace;
margin: 0;
padding: 20px;
}
#battle-container {
width: 800px;
height: 400px;
margin: 0 auto;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGElEQVQYlWNgYGD4z0AEYBxVSF+FAABqagIeiYWE9AAAAABJRU5ErkJggg==') repeat;
position: relative;
border: 4px solid #fff;
box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.pokemon {
width: 150px;
height: 150px;
position: absolute;
transition: all 0.3s;
}
#player-pokemon {
bottom: 20px;
left: 50px;
}
#enemy-pokemon {
top: 20px;
right: 50px;
}
.health-bar {
width: 200px;
height: 20px;
background: #eee;
border: 2px solid #000;
position: absolute;
}
#player-health {
bottom: 50px;
right: 50px;
}
#enemy-health {
top: 50px;
left: 50px;
}
.health-fill {
width: 100%;
height: 100%;
background: #2ecc71;
transition: width 0.5s;
}
#battle-menu {
position: absolute;
bottom: 0;
width: 100%;
height: 100px;
background: white;
border-top: 4px solid #000;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
padding: 10px;
}
.battle-button {
background: #3498db;
border: none;
color: white;
padding: 10px;
font-size: 16px;
cursor: pointer;
transition: all 0.2s;
}
.battle-button:hover {
background: #2980b9;
transform: scale(1.05);
}
.pokemon img {
width: 100%;
height: 100%;
object-fit: contain;
}
@keyframes attack {
0% { transform: translateX(0); }
50% { transform: translateX(50px); }
100% { transform: translateX(0); }
}
@keyframes hit {
0% { filter: brightness(1); }
50% { filter: brightness(2); }
100% { filter: brightness(1); }
}
#battle-text {
position: absolute;
bottom: 120px;
width: 100%;
text-align: center;
color: white;
font-size: 20px;
text-shadow: 2px 2px #000;
}
</style>
</head>
<body>
<div id="battle-container">
<div class="pokemon" id="enemy-pokemon">
<img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTUwIiBoZWlnaHQ9IjE1MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZmY5OTAwIi8+PC9zdmc+" alt="Enemy">
</div>
<div class="pokemon" id="player-pokemon">
<img src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTUwIiBoZWlnaHQ9IjE1MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjMzQ5OGRiIi8+PC9zdmc+" alt="Player">
</div>
<div class="health-bar" id="enemy-health">
<div class="health-fill"></div>
</div>
<div class="health-bar" id="player-health">
<div class="health-fill"></div>
</div>
<div id="battle-text"></div>
<div id="battle-menu">
<button class="battle-button" onclick="attack('tackle')">Tackle</button>
<button class="battle-button" onclick="attack('thunderbolt')">Thunderbolt</button>
<button class="battle-button" onclick="attack('heal')">Heal</button>
<button class="battle-button" onclick="attack('special')">Special Attack</button>
</div>
</div>
<script>
let playerHealth = 100;
let enemyHealth = 100;
let canAttack = true;
function updateHealth() {
document.querySelector('#player-health .health-fill').style.width = playerHealth + '%';
document.querySelector('#enemy-health .health-fill').style.width = enemyHealth + '%';
}
function showBattleText(text) {
const battleText = document.getElementById('battle-text');
battleText.textContent = text;
setTimeout(() => battleText.textContent = '', 2000);
}
function enemyAttack() {
const damage = Math.floor(Math.random() * 20) + 10;
playerHealth = Math.max(0, playerHealth - damage);
document.getElementById('player-pokemon').style.animation = 'hit 0.5s';
setTimeout(() => document.getElementById('player-pokemon').style.animation = '', 500);
showBattleText('Enemy attacks for ' + damage + ' damage!');
updateHealth();
}
function attack(type) {
if (!canAttack) return;
canAttack = false;
let damage = 0;
let text = '';
switch(type) {
case 'tackle':
damage = Math.floor(Math.random() * 15) + 5;
text = 'You used Tackle! ' + damage + ' damage!';
break;
case 'thunderbolt':
damage = Math.floor(Math.random() * 25) + 15;
text = 'You used Thunderbolt! ' + damage + ' damage!';
break;
case 'heal':
playerHealth = Math.min(100, playerHealth + 30);
text = 'You healed for 30 HP!';
break;
case 'special':
damage = Math.floor(Math.random() * 35) + 20;
text = 'You used Special Attack! ' + damage + ' damage!';
break;
}
document.getElementById('player-pokemon').style.animation = 'attack 0.5s';
if (damage > 0) {
enemyHealth = Math.max(0, enemyHealth - damage);
document.getElementById('enemy-pokemon').style.animation = 'hit 0.5s';
}
showBattleText(text);
updateHealth();
setTimeout(() => {
document.getElementById('player-pokemon').style.animation = '';
document.getElementById('enemy-pokemon').style.animation = '';
if (enemyHealth > 0) {
enemyAttack();
} else {
showBattleText('You won the battle!');
}
canAttack = true;
}, 1000);
}
</script>
</body>
</html>
This creates a simple but functional Pokémon battle interface with:
- A battle scene with two Pokémon (represented by colored rectangles)
- Health bars for both Pokémon
- Four attack buttons with different moves
- Basic attack animations
- Battle text display
- Turn-based combat system
- Healing ability
- Random damage calculations
To make it even more authentic, you could:
- Add actual Pokémon sprites
- Include sound effects
- Add more complex battle mechanics
- Include status effects
- Add type advantages
- Include more detailed animations
Would you like me to modify any part of this or add additional features?