From: 711215 <711215@pdsb.net> Date: Sun, 10 Jul 2022 14:56:19 +0000 (-0400) Subject: potion cd + potion ui X-Git-Url: http://git.skullheadx.com/nixos/static/git-favicon.png?a=commitdiff_plain;h=f3854306ab29e190a6bb52fcd7aee0f84cec825c;p=Pygame-Jam.git potion cd + potion ui --- diff --git a/Game.py b/Game.py index 40b1256..973229f 100644 --- a/Game.py +++ b/Game.py @@ -11,6 +11,7 @@ from World import World from EndScreen import EndScreen from UI.DashMeter import DashMeter from UI.HealthBar import HealthBar +from UI.PotionUI import PotionUI from Function.Portal import Transition @@ -34,6 +35,7 @@ class Game: self.scene = EndScreen() self.dashMeter = DashMeter(self.player.dashCooldown) self.healthBar = HealthBar() + self.potionUI = PotionUI() self.level = 1 self.scene.level = self.level @@ -74,6 +76,7 @@ class Game: self.dashMeter.update(self.player.lastDash) self.dashMeter.draw(surf) self.healthBar.draw(surf, self.player.health) + self.potionUI.draw(surf, self.player.potion_bag, self.player.potion_cooldown) if self.player.dead: self.scene.update() diff --git a/Player.py b/Player.py index 3709651..726156d 100644 --- a/Player.py +++ b/Player.py @@ -1,6 +1,7 @@ import pygame.key from Setup import * +import time from Actors import Actor from datetime import datetime, timedelta from Potion import Potion @@ -218,3 +219,13 @@ class Player(Actor): # current_health_display = createText(0, 0, 30, white, "Regular", str(self.health) + "/100")[0] # text_rect = current_health_display.get_rect(center=background_rect.center) # surf.blit(current_health_display, text_rect) + + + + def potion_cooldown_timer(self): + while self.potion_cooldown > 0: + self.potion_cooldown -= 1 + print(self.potion_cooldown) + time.sleep(1) + + diff --git a/Potion.py b/Potion.py index 3bd81ad..ed5fb19 100644 --- a/Potion.py +++ b/Potion.py @@ -1,4 +1,5 @@ from Setup import * +import threading class Potion: @@ -13,9 +14,14 @@ class Potion: def consume_potion(self, player): player.health += self.heal + if player.health > 100: + player.health = 100 + del player.potion_bag[0] - player.potion_cooldown = 5 + player.potion_cooldown = 30 + threading.Thread(target = player.potion_cooldown_timer).start() + + + - #def cooldown(self, player): - diff --git a/UI/PotionUI.py b/UI/PotionUI.py new file mode 100644 index 0000000..71b42e6 --- /dev/null +++ b/UI/PotionUI.py @@ -0,0 +1,26 @@ +from Setup import * +from Function.createText import createText +from CommonImports.colours import white + + +#Potion UI + +class PotionUI: + + def __init__(self): + return; + + def update(self): + return; + + def draw(self, surf, potion_bag, potion_cooldown): + #Amount of Potions Display + num_of_potions = createText(0, 0, 30, white, "Regular", str(len(potion_bag)) + " Potions")[0] + potion_text_rect = num_of_potions.get_rect(left = 20, top = 70) + surf.blit(num_of_potions, potion_text_rect) + + #Cooldown Display + if potion_cooldown > 0: + potion_cd_ui = createText(0, 0, 30, white, "Regular", str(potion_cooldown) + " until potion can be used")[0] + potion_cd_rect = num_of_potions.get_rect(left = 20, top = 100) + surf.blit(potion_cd_ui, potion_cd_rect)