From 6f3439045c773317c7b19aeec840104be06723c4 Mon Sep 17 00:00:00 2001 From: Berger Lena Date: Thu, 7 May 2026 19:39:09 +0200 Subject: [PATCH] feature: door basic mechanic - add door color and border color - add draw method to render the door - add take_damage method to handle health reduction and door breaking --- src/door.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/door.py b/src/door.py index 61a8fa7..5b388fb 100644 --- a/src/door.py +++ b/src/door.py @@ -10,4 +10,22 @@ class Door: self.max_hp = hp_value self.current_hp = hp_value - self.is_closed = False \ No newline at end of file + self.is_closed = False + + self.door_color = (245, 245, 220) + self.door_border_color = (100, 90, 80) + + def draw(self, screen): + # main space of the door with 20x100 px + pygame.draw.rect(screen, self.door_color, (self.x, self.y, 20, 100)) + + # doorframe 3px + pygame.draw.rect(screen, self.door_border_color, (self.x, self.y, 20, 100), 3) + + # when attacked and gets dmg reduces the health (if closed), door "breaks" when health = 0 + def take_damage(self, amount): + if self.is_closed: + self.current_hp -= amount + if self.current_hp <= 0: + self.current_hp = 0 + self.is_closed = False \ No newline at end of file