]> Skullheadx's Git Forge - Pygame-Jam.git/commitdiff
potion cd + potion ui
author711215 <711215@pdsb.net>
Sun, 10 Jul 2022 14:56:19 +0000 (10:56 -0400)
committer711215 <711215@pdsb.net>
Sun, 10 Jul 2022 14:56:19 +0000 (10:56 -0400)
Game.py
Player.py
Potion.py
UI/PotionUI.py [new file with mode: 0644]

diff --git a/Game.py b/Game.py
index 40b125600fef7bbec87ceb641e2d8734406f67e6..973229f4f8b2f1c2f48434f3626296518040bd14 100644 (file)
--- 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()
index 37096519e193e98a4f53a9973bed5d912d4c1b38..726156da432e2d3bfc18e80d164a1e607fc2d508 100644 (file)
--- 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)
+
+    
index 3bd81ad0026ade693dccd3c6dbaddcdf3cd83715..ed5fb19147920abc4a8dea3981bbf64c07fd1fed 100644 (file)
--- 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 (file)
index 0000000..71b42e6
--- /dev/null
@@ -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)