Merge branch 'feat/door_basic_mechanic' into 'main'

feature: door basic mechanic

See merge request swd25-bootcamp/silent-fh!9
This commit is contained in:
Haiden Niklas
2026-05-07 18:48:54 +00:00
2 changed files with 24 additions and 6 deletions
+14 -6
View File
@@ -1,5 +1,13 @@
import pygame
from src.settings import (
DOOR_WIDTH,
DOOR_HEIGHT,
DOOR_BORDER_WIDTH,
COLOR_DOOR_BEIGE,
COLOR_DOOR_BORDER
)
# using class to be able to reuse it
# as we will have multiple rooms to go in
class Door:
@@ -12,15 +20,15 @@ class Door:
self.current_hp = hp_value
self.is_closed = False
self.door_color = (245, 245, 220)
self.door_border_color = (100, 90, 80)
self.door_color = COLOR_DOOR_BEIGE
self.door_border_color = COLOR_DOOR_BORDER
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))
# door
pygame.draw.rect(screen, self.door_color, (self.x, self.y, DOOR_WIDTH, DOOR_HEIGHT))
# doorframe 3px
pygame.draw.rect(screen, self.door_border_color, (self.x, self.y, 20, 100), 3)
# doorframe
pygame.draw.rect(screen, self.door_border_color, (self.x, self.y, DOOR_WIDTH, DOOR_HEIGHT), DOOR_BORDER_WIDTH)
# when attacked and gets dmg reduces the health (if closed), door "breaks" when health = 0
def take_damage(self, amount):
+10
View File
@@ -2,3 +2,13 @@
DESK_WIDTH = 70
DESK_HEIGHT = 40
# --- DOOR ---
DOOR_WIDTH = 20
DOOR_HEIGHT = 100
DOOR_BORDER_WIDTH = 3
COLOR_DOOR_BEIGE = (245, 245, 220)
COLOR_DOOR_BORDER = (100, 90, 80)
COLOR_HP_BAR_GREEN = (0, 255, 0)
COLOR_HP_BAR_BG = (50, 50, 50)