so i made a simple game in python useing pygame,
when i put
kn=knight(100,100,40,50,2)
it stops working how do i fix that my code is
import pygame
pygame.init()
clock=pygame.time.Clock()
fps=60
bottom_panel=100
screen_width=800
screem_height=400+bottom_panel
screen = pygame.display.set_mode((screen_width, screem_height))
pygame.display.set_caption('Hero World Battle')
background_img=pygame.image.load('something.png')
panel_img=pygame.image.load('pixil-frame-0(1).png')
def draw_bg():
clock.tick(fps)
screen.blit(background_img, (0,0))
def draw_panel():
screen.blit(panel_img, (-110,255))
class knight():
def __init__(self,x,y,max_hp,power,potions):
self.max_hp=max_hp
self.hp=max_hp
self.power=power
self.start_potions=potions
self.alive=True
self.image=pygame.image.load('/img/Hero Knight/Sprites/HeroKnight/Idle/HeroKnight_Idle_0.png')
self.rect=self.image.get_rect()
self.rect.center(x,y)
def draw(self):
screen.blit(self.image,self.rect)
kn=knight(100,100,40,50,2)
run=True
while run:
clock.tick(fps)
draw_bg()
draw_panel()
for event in pygame.event.get():
if event.type == pygame.QUIT:
run=False
print(run)
pygame.display.update()
pygame.quit()
What I have tried:
i have tried chageing kn but it still happen also i have tried removeing code that dose not help