Added new classes

Edited player.get_damage() function
This commit is contained in:
Christian
2024-08-20 22:10:55 +02:00
parent 6742e4585d
commit b6590d33b8
3 changed files with 51 additions and 5 deletions

38
interface.py Normal file
View File

@@ -0,0 +1,38 @@
import pygame
class UIelement(object):
def __init__(self, screen, name, posx, posy) -> None:
self.screen = screen
self.name = name
self.posx = posx
self.posy = posy
pass
pass
class Healthbar(UIelement):
def __init__(self, screen, name, posx, posy, width, height,playerhealth) -> None:
super().__init__(screen, name, posx, posy)
self.width = width
self.height = height
self.max_width = width
self.max_health = playerhealth
self.health = playerhealth
def update(self, playerheatlh):
grundwert = self.max_health
prozentwert = playerheatlh
prozent = (playerheatlh/grundwert)
print(prozent)
print(prozentwert)
print(playerheatlh)
#Update until playerhealth not zero
if(self.health > 0):
res = self.max_width*prozent
self.health = res
elif self.health < 0:
self.health = 0
def render(self, screen):
pygame.draw.rect(screen, (255,0,0), (self.posx, self.posy, self.health, self.height))
pass