Creating a fully functional Pokémon battle screen game like on the Game Boy is a big project, but I can help you build a simple, fun, text-based battle simulation in Python that captures the spirit of those classic battles! This will include:
- Two Pokémon with HP, moves, and types
- Turn-based attacks
- Simple damage calculation
- Status updates and a battle loop
If you want a graphical version, that would require a game library like Pygame, but for now, here’s a fun, interactive console version you can run immediately.
Pokémon Battle Simulator (Text-Based)
import random
import time
# Define some Pokémon and moves
class Move:
def __init__(self, name, power, move_type):
self.name = name
self.power = power
self.type = move_type
class Pokemon:
def __init__(self, name, p_type, max_hp, moves):
self.name = name
self.type = p_type
self.max_hp = max_hp
self.hp = max_hp
self.moves = moves
def is_fainted(self):
return self.hp <= 0
def take_damage(self, damage):
self.hp = max(self.hp - damage, 0)
def heal(self, amount):
self.hp = min(self.hp + amount, self.max_hp)
# Simple type effectiveness chart
type_chart = {
('Fire', 'Grass'): 2.0,
('Fire', 'Water'): 0.5,
('Water', 'Fire'): 2.0,
('Water', 'Grass'): 0.5,
('Grass', 'Water'): 2.0,
('Grass', 'Fire'): 0.5,
}
def type_effectiveness(move_type, target_type):
return type_chart.get((move_type, target_type), 1.0)
def calculate_damage(attacker, defender, move):
base_damage = move.power
effectiveness = type_effectiveness(move.type, defender.type)
# Add some randomness
damage = int(base_damage * effectiveness * random.uniform(0.85, 1.0))
return damage, effectiveness
def print_hp_bar(pokemon):
bar_length = 20
hp_ratio = pokemon.hp / pokemon.max_hp
filled_length = int(bar_length * hp_ratio)
bar = '█' * filled_length + '-' * (bar_length - filled_length)
print(f"{pokemon.name} HP: [{bar}] {pokemon.hp}/{pokemon.max_hp}")
def battle_turn(attacker, defender):
print(f"\n{attacker.name}'s turn!")
print("Choose a move:")
for i, move in enumerate(attacker.moves):
print(f"{i + 1}. {move.name} (Power: {move.power}, Type: {move.type})")
while True:
try:
choice = int(input("Enter move number: ")) - 1
if 0 <= choice < len(attacker.moves):
break
else:
print("Invalid choice, try again.")
except ValueError:
print("Please enter a number.")
move = attacker.moves[choice]
damage, effectiveness = calculate_damage(attacker, defender, move)
defender.take_damage(damage)
print(f"{attacker.name} used {move.name}!")
if effectiveness > 1:
print("It's super effective!")
elif effectiveness < 1:
print("It's not very effective...")
print(f"{defender.name} took {damage} damage.")
print_hp_bar(defender)
def main():
# Define moves
ember = Move("Ember", 40, "Fire")
vine_whip = Move("Vine Whip", 45, "Grass")
water_gun = Move("Water Gun", 40, "Water")
tackle = Move("Tackle", 35, "Normal")
# Define Pokémon
charmander = Pokemon("Charmander", "Fire", 100, [ember, tackle])
bulbasaur = Pokemon("Bulbasaur", "Grass", 100, [vine_whip, tackle])
squirtle = Pokemon("Squirtle", "Water", 100, [water_gun, tackle])
# Player chooses Pokémon
print("Choose your Pokémon:")
pokemons = [charmander, bulbasaur, squirtle]
for i, p in enumerate(pokemons):
print(f"{i + 1}. {p.name} (Type: {p.type})")
while True:
try:
choice = int(input("Enter number: ")) - 1
if 0 <= choice < len(pokemons):
player_pokemon = pokemons[choice]
break
else:
print("Invalid choice, try again.")
except ValueError:
print("Please enter a number.")
# Opponent Pokémon (random)
opponent_pokemon = random.choice([p for p in pokemons if p != player_pokemon])
print(f"\nYou chose {player_pokemon.name}!")
print(f"Your opponent chose {opponent_pokemon.name}!")
# Battle loop
while True:
print("\n--- Battle Status ---")
print_hp_bar(player_pokemon)
print_hp_bar(opponent_pokemon)
# Player turn
battle_turn(player_pokemon, opponent_pokemon)
if opponent_pokemon.is_fainted():
print(f"\n{opponent_pokemon.name} fainted! You win!")
break
# Opponent turn (random move)
print(f"\n{opponent_pokemon.name}'s turn!")
opp_move = random.choice(opponent_pokemon.moves)
damage, effectiveness = calculate_damage(opponent_pokemon, player_pokemon, opp_move)
player_pokemon.take_damage(damage)
print(f"{opponent_pokemon.name} used {opp_move.name}!")
if effectiveness > 1:
print("It's super effective!")
elif effectiveness < 1:
print("It's not very effective...")
print(f"{player_pokemon.name} took {damage} damage.")
print_hp_bar(player_pokemon)
if player_pokemon.is_fainted():
print(f"\n{player_pokemon.name} fainted! You lose!")
break
time.sleep(1)
if __name__ == "__main__":
main()
How to play:
- Run the script.
- Choose your Pokémon.
- Select moves each turn.
- Try to defeat the opponent’s Pokémon!
What makes it fun?
- Type effectiveness matters.
- Random damage adds unpredictability.
- Simple but strategic move choices.
- Classic Pokémon feel with HP bars and turn-based combat.
If you want, I can help you extend this with:
- More Pokémon and moves
- Status effects (paralysis, burn, etc.)
- Items and healing
- A graphical interface with Pygame
Just ask! Would you like me to help with that?