Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- class Pokemon:
- def __init__(self, nm, atak=5, damf=5):
- self.hp = 100
- self.name = nm
- self.atk = atak
- self.df = damf
- self.x = 100
- self.y = 100
- def attack(self, other):
- if self.hp == 0 or other.hp == 0:
- return
- else:
- damage = self.atk - other.df
- if damage > 0:
- if self.type == 'water' and other.type == 'fire':
- other.hp -= 3 * damage
- elif self.type == 'grass' and other.type == 'fire':
- other.hp -= damage
- other.df /= 2
- elif self.type == 'electric' and other.type == 'water':
- other.hp -= damage
- other.df = 0
- else:
- other.hp -= damage
- else:
- other.hp -= 1
- def get_name(self):
- return self.name
- def get_hp(self):
- return self.hp
- def get_atk(self):
- return self.atk
- def get_df(self):
- return self.df
- class WaterPokemon(Pokemon):
- type = 'water'
- def __init__(self, nm, atak, damf):
- super().__init__(nm, atak, damf)
- self.x = 100
- self.y = 100
- self.kind = PhotoImage(file="1.png")
- self.ob = Label(root, image=self.kind)
- class FirePokemon(Pokemon):
- type = 'fire'
- def __init__(self, nm, atak, damf):
- super().__init__(nm, atak, damf)
- self.x = 150
- self.y = 150
- self.kind = PhotoImage(file="2.png")
- self.ob = Label(root, image=self.kind)
- class GrassPokemon(Pokemon):
- type = 'grass'
- def __init__(self, nm, atak, damf):
- super().__init__(nm, atak, damf)
- self.x = 100
- self.y = 100
- self.kind = PhotoImage(file="1.png")
- self.ob = Label(root, image=self.kind)
- class ElectricPokemon(Pokemon):
- def __init__(self, atak, damf):
- super().__init__(atak, damf)
- self.x = 100
- self.y = 100
- self.kind = PhotoImage(file="1.png")
- self.ob = Label(root, image=self.kind)
- self.type = 'electric'
- root = Tk()
- root.geometry('800x600+200+100')
- pikachu = WaterPokemon('Pikachu', 35, 60)
- pikachu.ob.place(x=100, y= 100)
- kop = FirePokemon('KopKop', 35, 60)
- kop.ob.place(x=300, y= 100)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement