hp_bar pod tarczami liczony na podstawie hp knightow
This commit is contained in:
parent
4ab8065879
commit
9aa9552499
@ -26,7 +26,6 @@ class Game:
|
||||
self.bg = pygame.image.load("./resources/textures/bg.jpg")
|
||||
self.screens = {'credits': Credits(self.screen, self.clock), 'options': Options(self.screen, self.clock)}
|
||||
|
||||
|
||||
def main_menu(self):
|
||||
menu = MainMenu(self.screen, self.clock, self.bg,
|
||||
self.game,
|
||||
@ -37,7 +36,6 @@ class Game:
|
||||
def game(self):
|
||||
logs = Logs(self.screen)
|
||||
level = Level(self.screen, logs)
|
||||
stats = Stats(self.screen, level.list_knights_blue, level.list_knights_red)
|
||||
|
||||
# setup clock for rounds
|
||||
NEXT_TURN = pygame.USEREVENT + 1
|
||||
@ -45,6 +43,9 @@ class Game:
|
||||
|
||||
# create level
|
||||
level.create_map()
|
||||
stats = Stats(self.screen,
|
||||
level.list_knights_blue,
|
||||
level.list_knights_red) # has to be called after level.create_map()
|
||||
|
||||
print_numbers_flag = False
|
||||
running = True
|
||||
@ -60,8 +61,6 @@ class Game:
|
||||
running = False
|
||||
if event.key == pygame.K_n:
|
||||
print_numbers_flag = not print_numbers_flag
|
||||
if event.key == pygame.K_r:
|
||||
stats.red_team_hp_bar.take_dmg(5)
|
||||
if event.type == NEXT_TURN: # is called every 'TURN_INTERVAL' milliseconds
|
||||
level.handle_turn()
|
||||
|
||||
|
25
ui/stats.py
25
ui/stats.py
@ -15,8 +15,25 @@ class Stats:
|
||||
self.screen = screen
|
||||
self.x = (GRID_CELL_PADDING + GRID_CELL_SIZE) * COLUMNS + BORDER_WIDTH + 15
|
||||
self.y = 5
|
||||
self.blue_team_hp_bar = HealthBar(self.screen, pygame.Rect(self.x + 30, self.y + 210, 100, 15), current_hp=50, max_hp=100)
|
||||
self.red_team_hp_bar = HealthBar(self.screen, pygame.Rect(self.x + 210, self.y + 210, 100, 15), 100, 100)
|
||||
self.max_hp = 0
|
||||
self.blue_team_current_hp = 0
|
||||
self.red_team_current_hp = 0
|
||||
|
||||
for knight in list_knights_red:
|
||||
self.max_hp += knight.max_hp
|
||||
self.red_team_current_hp += knight.current_hp
|
||||
|
||||
for knight in list_knights_blue:
|
||||
self.blue_team_current_hp += knight.current_hp
|
||||
|
||||
self.blue_team_hp_bar = HealthBar(self.screen,
|
||||
pygame.Rect(self.x + 30, self.y + 210, 100, 15),
|
||||
current_hp=self.blue_team_current_hp,
|
||||
max_hp=self.max_hp)
|
||||
self.red_team_hp_bar = HealthBar(self.screen,
|
||||
pygame.Rect(self.x + 210, self.y + 210, 100, 15),
|
||||
current_hp=self.red_team_current_hp,
|
||||
max_hp=self.max_hp)
|
||||
|
||||
def update(self):
|
||||
|
||||
@ -40,9 +57,9 @@ class Stats:
|
||||
|
||||
# texts
|
||||
draw_text('Rycerze: ' + str(len(self.list_knights_blue)), FONT_DARK, self.screen, self.x + 35, self.y + 240, 18) # blue
|
||||
draw_text('Fortece: ' + str(len(self.list_knights_red)), FONT_DARK, self.screen, self.x + 35, self.y + 270, 18) # red
|
||||
draw_text('Fortece: 0', FONT_DARK, self.screen, self.x + 35, self.y + 270, 18) # red
|
||||
|
||||
draw_text('Rycerze: 4', FONT_DARK, self.screen, self.x + 215, self.y + 240, 18)
|
||||
draw_text('Rycerze: ' + str(len(self.list_knights_red)), FONT_DARK, self.screen, self.x + 215, self.y + 240, 18)
|
||||
draw_text('Fortece: 0', FONT_DARK, self.screen, self.x + 215, self.y + 270, 18)
|
||||
|
||||
# points
|
||||
|
Loading…
Reference in New Issue
Block a user