Started issue Gameplay: Economy & Base #4

This commit is contained in:
2026-11-30 23:20:10 +01:00
parent 451635947f
commit b60c25364b
6 changed files with 40 additions and 8 deletions
+16 -1
View File
@@ -49,6 +49,14 @@ class GamePlay(BaseScreen):
self.enemy = Enemy(self.game, 0.5, 200)
self.enemy_group.add(self.enemy)
self.money_label = pgi.elements.UILabel(
relative_rect=pg.Rect(self.width - 200, 50, 200, 30), # x, y, Breite, Höhe
text=f"Geld: {self.game.money}",
manager=self.game.ui_manager,
)
self.game.on_money_changed = lambda m: self.money_label.set_text(f"Geld: {m}")
self.buy_button = pgi.elements.UIButton(
relative_rect=pg.Rect(
self.width - 200,
@@ -136,6 +144,8 @@ class GamePlay(BaseScreen):
if not any(tw.tile_pos == self.tile_pos for tw in self.tower_group):
tower = Tower(self.game, self.mpos, self.tile_pos, 'cannon')
self.tower_group.add(tower)
#TODO richtier Kauf wert
self.game.money -= 50
self.bought = False
elif event.button == 3 and self.tile_pos is not None:
@@ -145,7 +155,12 @@ class GamePlay(BaseScreen):
elif event.type == pgi.UI_BUTTON_PRESSED:
if event.ui_element == self.buy_button:
self.bought = True
#TODO buy new Tower (cost)
if self.game.money >= 50:
self.bought = True
else:
#TODO display on screen for user
print("You have insufficient money")
# self.tower = Tower(self.game, self.mpos, self.tile_pos, 'cannon')
if event.ui_element == self.cancel_button:
self.bought = False