Merge branch 'main' into feat/startscreen

This commit is contained in:
Kevin Baumgartner
2026-05-07 20:43:00 +02:00
89 changed files with 91 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
import pygame
from src.settings import DESK_WIDTH, DESK_HEIGHT
class Desk:
def __init__(self, x, y):
# each desk must be positioned with its own x/y coordinates
self.x = x
self.y = y
# size for collision rect and table
self.rect = pygame.Rect(self.x, self.y, DESK_WIDTH, DESK_HEIGHT)
try:
self.image = pygame.image.load("assets/furniture/desk.png").convert_alpha()
# scale the sprite to match collision rect
self.image = pygame.transform.scale(self.image, (DESK_WIDTH, DESK_HEIGHT))
except Exception as e:
print(f"Error loading desk sprite: {e}")
self.image = None
# check if player touches table
def check_collision(self, player_rect):
return self.rect.colliderect(player_rect)
# draw table - use sprite and as fallback a brown rect
def draw(self, screen):
if self.image:
screen.blit(self.image, self.rect)
else:
pygame.draw.rect(screen, (193, 69, 19), self.rect)
+31
View File
@@ -0,0 +1,31 @@
import pygame
# using class to be able to reuse it
# as we will have multiple rooms to go in
class Door:
def __init__(self, x, y, hp_value):
# for each door we can set our own x/y position
self.x = x
self.y = y
self.max_hp = hp_value
self.current_hp = hp_value
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
+4
View File
@@ -0,0 +1,4 @@
# --- DESK ---
DESK_WIDTH = 70
DESK_HEIGHT = 40