commit bc8cd0d1d19ad46521c3aecc581f58fecc0aaf07
parent 44923054aa0017485c43540e91a735c604cb1c56
Author: Erik Letson <hmagellan@hmagellan.com>
Date: Mon, 30 Aug 2021 21:17:56 -0500
now displays stat bars
Diffstat:
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/src/game.py b/src/game.py
@@ -312,6 +312,29 @@ class Game(object):
if self.location_element != None:
surface.blit(self.location_element, self.location_element_pos)
+ # Last is the party stat display
+ x_mod = 0
+ for c in self.party:
+
+ # First three meters
+ x2 = 0
+ for s in ("hp", "mp", "sp"):
+ if self.party[c][s] > self.party[c][s + "_mod"]:
+ yr = round(((self.party[c][s] - self.party[c][s + "_mod"]) / self.party[c][s]) * 38)
+ sq = pygame.Surface((8, yr))
+ sq.fill((205 if s == "hp" else 0, 205 if s == "sp" else 0, 205 if s == "mp" else 0))
+ surface.blit(sq, (83 + (x_mod * 137) + (x2 * 13), 587 + (38 - yr)))
+ x2 += 1
+
+ # XP meter
+ xpyr = round((self.party[c]["xp"] / calculate_xp_to_level(self.party[c]["level"])) * 38)
+ if xpyr > 0:
+ xpsq = pygame.Surface((8, xpyr))
+ xpsq.fill((205, 205, 0))
+ surface.blit(xpsq, (122 + (x_mod * 137), 587 + (38 - xpyr)))
+
+ x_mod += 1
+
def collect_game_data(self):
"""
Collect a bunch of info about the current
diff --git a/src/gamelib.py b/src/gamelib.py
@@ -81,3 +81,9 @@ def load_image(filename, alpha = False):
im = pygame.image.load(os.path.join(IMAGE_PATH, filename)).convert()
return im
+def calculate_xp_to_level(level):
+ """
+ Calculate how much XP is required to go from 'level' to
+ 'level' + 1.
+ """
+ return ((6 * (2 * level)) ** 2) + 1