feature: door basic mechanic
- Move hardcoded door size and colors to settings.py - Update Door class to use constants for drawing
This commit is contained in:
+14
-6
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user