Added new classes
Edited player.get_damage() function
This commit is contained in:
38
interface.py
Normal file
38
interface.py
Normal 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
|
||||
Reference in New Issue
Block a user