From b2ba681fb514a0a0c9b25aaf15a2c70811887b1d Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:06:36 +0200 Subject: [PATCH 01/21] initial commit --- src/map.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/map.py diff --git a/src/map.py b/src/map.py new file mode 100644 index 0000000..e69de29 From bdd633ff8527e7b703923089ac2db3a7fd244884 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:13:11 +0200 Subject: [PATCH 02/21] defined colors and tile/screen size --- src/map.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/map.py b/src/map.py index e69de29..6a2731f 100644 --- a/src/map.py +++ b/src/map.py @@ -0,0 +1,16 @@ +import pygame + +tile_size = 30 +screen_w = 1800 +screen_h = 900 + +color_wall = (30, 20, 40) # black like +color_room = (75, 40, 55) # dark red-violet +color_hall = (35, 65, 45) # dark green +color_door = (40, 90, 110) # dark blue +color_void = (10, 10, 15) # a little more black +color_text = (220, 180, 210) # rose +color_border = (55, 35, 70) # dark violet + + + From cc06400c56eead5f09c28aaa77057b279a8d3376 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:25:05 +0200 Subject: [PATCH 03/21] Map-Start, safe commit --- src/map.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/map.py b/src/map.py index 6a2731f..558c4f4 100644 --- a/src/map.py +++ b/src/map.py @@ -13,4 +13,8 @@ color_text = (220, 180, 210) # rose color_border = (55, 35, 70) # dark violet +class Map: + def __init__(self): + self.map = [ + ] From c8430ac7f4be955bb28871c69a575128d8e101f6 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:33:12 +0200 Subject: [PATCH 04/21] map basic tile structure --- src/map.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/map.py b/src/map.py index 558c4f4..9324d8e 100644 --- a/src/map.py +++ b/src/map.py @@ -16,5 +16,22 @@ color_border = (55, 35, 70) # dark violet class Map: def __init__(self): self.map = [ - + "WWWWWWWWWWWWWWWWWGGWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WWWWWWWWWWWWWTTWWGGWWWWWWWWWWWWWTTWWWTTWWWWWWWWWWWWW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" ] From 884cb153e89f86f0b7513cb25782ce54b2b61476 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:44:40 +0200 Subject: [PATCH 05/21] add room description --- src/map.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/map.py b/src/map.py index 9324d8e..a2ee5a8 100644 --- a/src/map.py +++ b/src/map.py @@ -35,3 +35,11 @@ class Map: "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" ] + + self.room_decription = [ + (8, 3, "Room 102"), + (27, 3, "Room 103"), + (43, 3, "Room 105") + ] + + From f67f349a5e3e826ce53b3739fd4767979c65a5f3 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:48:55 +0200 Subject: [PATCH 06/21] function:get_tile - check if in map --- src/map.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/map.py b/src/map.py index a2ee5a8..d313b41 100644 --- a/src/map.py +++ b/src/map.py @@ -42,4 +42,9 @@ class Map: (43, 3, "Room 105") ] + def get_tile(self, column: int, row: int): + if 0 <= row < len(self.map) and 0 <= column < len(self.map[row]): + return self.map[row][column] + return "W" + From 796bb5532f82dae2f2bf9b6b3f1d162ddcf85024 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:06:36 +0200 Subject: [PATCH 07/21] initial commit --- src/map.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/map.py diff --git a/src/map.py b/src/map.py new file mode 100644 index 0000000..e69de29 From 75741f18ee388182e47033dd8c6480c77dfb685b Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:13:11 +0200 Subject: [PATCH 08/21] defined colors and tile/screen size --- src/map.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/map.py b/src/map.py index e69de29..6a2731f 100644 --- a/src/map.py +++ b/src/map.py @@ -0,0 +1,16 @@ +import pygame + +tile_size = 30 +screen_w = 1800 +screen_h = 900 + +color_wall = (30, 20, 40) # black like +color_room = (75, 40, 55) # dark red-violet +color_hall = (35, 65, 45) # dark green +color_door = (40, 90, 110) # dark blue +color_void = (10, 10, 15) # a little more black +color_text = (220, 180, 210) # rose +color_border = (55, 35, 70) # dark violet + + + From 40ae16e467f751a70e8b6918b5515b1ecd50973d Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:25:05 +0200 Subject: [PATCH 09/21] Map-Start, safe commit --- src/map.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/map.py b/src/map.py index 6a2731f..558c4f4 100644 --- a/src/map.py +++ b/src/map.py @@ -13,4 +13,8 @@ color_text = (220, 180, 210) # rose color_border = (55, 35, 70) # dark violet +class Map: + def __init__(self): + self.map = [ + ] From 83dcf7b51c35dd1cf5867cae21690da23bdeb528 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:33:12 +0200 Subject: [PATCH 10/21] map basic tile structure --- src/map.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/map.py b/src/map.py index 558c4f4..9324d8e 100644 --- a/src/map.py +++ b/src/map.py @@ -16,5 +16,22 @@ color_border = (55, 35, 70) # dark violet class Map: def __init__(self): self.map = [ - + "WWWWWWWWWWWWWWWWWGGWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WWWWWWWWWWWWWTTWWGGWWWWWWWWWWWWWTTWWWTTWWWWWWWWWWWWW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" + "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" ] From 833c735d38d92d76af502109d2d78578eed3ae0f Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:44:40 +0200 Subject: [PATCH 11/21] add room description --- src/map.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/map.py b/src/map.py index 9324d8e..a2ee5a8 100644 --- a/src/map.py +++ b/src/map.py @@ -35,3 +35,11 @@ class Map: "WGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" ] + + self.room_decription = [ + (8, 3, "Room 102"), + (27, 3, "Room 103"), + (43, 3, "Room 105") + ] + + From 7c6d8594d7a2dfa839562f96e7b919921a077e97 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 19:48:55 +0200 Subject: [PATCH 12/21] function:get_tile - check if in map --- src/map.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/map.py b/src/map.py index a2ee5a8..d313b41 100644 --- a/src/map.py +++ b/src/map.py @@ -42,4 +42,9 @@ class Map: (43, 3, "Room 105") ] + def get_tile(self, column: int, row: int): + if 0 <= row < len(self.map) and 0 <= column < len(self.map[row]): + return self.map[row][column] + return "W" + From 9200b8257f8c17addb5b9b8d78d411becfd0c6dd Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 20:02:35 +0200 Subject: [PATCH 13/21] tile accedd control function + tile update --- src/map.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/map.py b/src/map.py index d313b41..3d9f838 100644 --- a/src/map.py +++ b/src/map.py @@ -16,23 +16,23 @@ color_border = (55, 35, 70) # dark violet class Map: def __init__(self): self.map = [ - "WWWWWWWWWWWWWWWWWGGWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" - "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWGGWRRRRRRRRRRRR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RRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" + "WWWWWWWWWWWWWDDWWHHWWWWWWWWWWWWWDDWWWDDWWWWWWWWWWWWW" + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW" + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW" + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW" + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW" + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW" "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" ] @@ -47,4 +47,8 @@ class Map: return self.map[row][column] return "W" + def is_accessible(self, column: int, row: int) -> bool: + return self.get_tile(column, row) in ("R", "D,", "H", "S") + + From 5e7a3197c0539324a794ce301d2e1c9d7f18a196 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 20:37:08 +0200 Subject: [PATCH 14/21] def draw_map to display the map --- src/map.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/src/map.py b/src/map.py index 3d9f838..73edd07 100644 --- a/src/map.py +++ b/src/map.py @@ -1,9 +1,11 @@ import pygame +# Fenstergröße und Tile Größe (Felder) tile_size = 30 screen_w = 1800 screen_h = 900 +# Farben für die einzelnen Tiles color_wall = (30, 20, 40) # black like color_room = (75, 40, 55) # dark red-violet color_hall = (35, 65, 45) # dark green @@ -15,8 +17,11 @@ color_border = (55, 35, 70) # dark violet class Map: def __init__(self): + + # Map wird mit "Tiles" (30x30 Feldern aufgebaut + # W=Wall, R=Room, S=Start, H=Hall, D=Door self.map = [ - "WWWWWWWWWWWWWWWWWHHWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" + "WWWWWWWWWWWWWWWWWSSWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" @@ -36,19 +41,70 @@ class Map: "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" ] + # Raumbeschreibung in (Spalte, Zeile, Beschreibung) + # gibt an wo der Raumname auf dem Bildschirm angezeigt wird self.room_decription = [ (8, 3, "Room 102"), (27, 3, "Room 103"), (43, 3, "Room 105") ] + + def get_tile(self, column: int, row: int): + # ein check, ob die Position innerhalb der Map liegt if 0 <= row < len(self.map) and 0 <= column < len(self.map[row]): + # gibt den Buchstaben der Position zurück return self.map[row][column] + # falls Außerhalb der Map, ein return als Wand return "W" def is_accessible(self, column: int, row: int) -> bool: + # gibt True zurück, wenn der Spieler das Tile betreten darf return self.get_tile(column, row) in ("R", "D,", "H", "S") + def draw_map(self, surface: pygame.Surface, font: pygame.font.Font, cam_x: int = 0, cam_y: int = 0) -> None: + + # Dict, dass jedem Buchstaben eine Farbe zuordnet + color_for = { + "W": color_wall, + "R": color_room, + "H": color_hall, + "D": color_door, + "S": color_hall, + } + + # äußere Schleife Zeile für Zeile + for row_nr in range(len(self.map)): + # innerer Loop für jedes Zeichen in der Zeile + for column_nr in range(len(self.map[row_nr])): + # holt sich den Buchstaben und speichert ihn in der Variable mark + mark = self.map[row_nr][column_nr] + # sucht die Farbe für den Buchstaben - falls unbekannt -> color_void + color = color_for.get(mark, color_void) + + # errechnet die Position des Tiles auf dem Bildschirm mit "column_nr * tile_size", "- cam_x" verschiebt alles mit der Kamera + rect = pygame.Rect( + column_nr * tile_size - cam_x, + row_nr * tile_size - cam_y, + # Tile-Breite + tile_size, + # Tile-Höhe + tile_size, + ) + + # das Rechteck ind er Farbe zeichnen + pygame.draw.rect(surface, color, rect) + + # die Wände sollen einen zusätzlichen Rand haben mit 1 = Wandbreite in Pixel + if mark = "W": + pygame.draw.rect(surface, color_border, rect, 1) + + + + + + + From 4207ebc45ae8236bfc12af8f4df89fd381f97dc8 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 20:45:07 +0200 Subject: [PATCH 15/21] wall border and sticky description --- src/map.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/map.py b/src/map.py index 73edd07..3753460 100644 --- a/src/map.py +++ b/src/map.py @@ -63,6 +63,8 @@ class Map: # gibt True zurück, wenn der Spieler das Tile betreten darf return self.get_tile(column, row) in ("R", "D,", "H", "S") + + # Funktion, um die Map zu erstellen def draw_map(self, surface: pygame.Surface, font: pygame.font.Font, cam_x: int = 0, cam_y: int = 0) -> None: # Dict, dass jedem Buchstaben eine Farbe zuordnet @@ -97,9 +99,23 @@ class Map: pygame.draw.rect(surface, color, rect) # die Wände sollen einen zusätzlichen Rand haben mit 1 = Wandbreite in Pixel - if mark = "W": + if mark == "W": pygame.draw.rect(surface, color_border, rect, 1) + # geht die Beschriftungen durch + for i in range(len(self.room_decription)): + # entpackt das Tupel in 3 Variablen: column, row, text + column, row, text = self.room_decription[i] + + # die Tile-Koordinaten in Pixel umrechnen und addieren von 2, damit der Text nicht ganz am Rand klebt + px = column + tile_size - cam_x + 2 + py = row + tile_size - cam_y + 2 + + # Text-Bild mit fon.render() + # True gibt eine glattere Schrift + # blit() fixiert den Text auf dem Bildschirm + surface.blit(font.render(text, True, color_text), (px, py)) + From 9b74401b08796ef19c5483d4be5f0d5440cf0df3 Mon Sep 17 00:00:00 2001 From: Berger Lena Date: Thu, 7 May 2026 20:47:42 +0200 Subject: [PATCH 16/21] feature: door basic mechanic - Move hardcoded door size and colors to settings.py - Update Door class to use constants for drawing --- src/door.py | 20 ++++++++++++++------ src/settings.py | 10 ++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/door.py b/src/door.py index 5b388fb..7bfc636 100644 --- a/src/door.py +++ b/src/door.py @@ -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): diff --git a/src/settings.py b/src/settings.py index 4055ea3..edece49 100644 --- a/src/settings.py +++ b/src/settings.py @@ -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) \ No newline at end of file From da184af639cb7e34b96c1a9c6ea468e94e6185ac Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 20:52:34 +0200 Subject: [PATCH 17/21] pygame.init() to display the first map --- src/map.py | 54 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/src/map.py b/src/map.py index 3753460..651581d 100644 --- a/src/map.py +++ b/src/map.py @@ -21,24 +21,24 @@ class Map: # Map wird mit "Tiles" (30x30 Feldern aufgebaut # W=Wall, R=Room, S=Start, H=Hall, D=Door self.map = [ - "WWWWWWWWWWWWWWWWWSSWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WRRRRRRRRRRRRRRRWHHWRRRRRRRRRRRRRRRWRRRRRRRRRRRRRRRW" - "WWWWWWWWWWWWWDDWWHHWWWWWWWWWWWWWDDWWWDDWWWWWWWWWWWWW" - "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH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HHHHHHHHHHHHHHHHHHHHHHHW", + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW", + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW", + "WHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHW", + "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", ] # Raumbeschreibung in (Spalte, Zeile, Beschreibung) @@ -117,7 +117,25 @@ class Map: surface.blit(font.render(text, True, color_text), (px, py)) +if __name__ == "__main__": + pygame.init() + screen = pygame.display.set_mode((screen_w, screen_h)) + font = pygame.font.SysFont("monospace", 12, bold=True) + clock = pygame.time.Clock() + + my_map = Map() + + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + exit() + + screen.fill(color_void) + my_map.draw_map(screen, font) + pygame.display.flip() + clock.tick(60) From dbbd40b58aac67195478ae0dc2a039968d05c65a Mon Sep 17 00:00:00 2001 From: Kevin Baumgartner Date: Thu, 7 May 2026 20:55:22 +0200 Subject: [PATCH 18/21] feat(text_input): add text input class with initialization --- src/text_input.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/text_input.py diff --git a/src/text_input.py b/src/text_input.py new file mode 100644 index 0000000..e215b96 --- /dev/null +++ b/src/text_input.py @@ -0,0 +1,20 @@ +import pygame + +class TextInput: + def __init__(self, width, height, pos_x, pos_y): + self.rect = pygame.Rect(pos_x, pos_y, width, height) + + self.font = pygame.font.SysFont("Arial", 22) + + # input text + self.text = "" + + self.active = True + + # colors + self.text_color = (255, 255, 255) + self.border_color = (255, 255, 255) + self.active_border_color = (0, 255, 0) + self.background_color = (30, 30, 30) + + From b625acdd60e0919216e7aae24a002b38d675235d Mon Sep 17 00:00:00 2001 From: Kevin Baumgartner Date: Thu, 7 May 2026 21:12:02 +0200 Subject: [PATCH 19/21] feat(text_input): add draw function --- src/text_input.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/text_input.py b/src/text_input.py index e215b96..6272f3b 100644 --- a/src/text_input.py +++ b/src/text_input.py @@ -16,5 +16,29 @@ class TextInput: self.border_color = (255, 255, 255) self.active_border_color = (0, 255, 0) self.background_color = (30, 30, 30) - + def handle_event(self, event): + # todo check keyboard input events + pass + + def draw(self, screen): + # draw background of input box + pygame.draw.rect(screen, self.background_color, self.rect) + + # change border color depending if input box is active or not + if self.active: + border_color = self.active_border_color + else: + border_color = self.border_color + + # draw border + pygame.draw.rect(screen, border_color, self.rect, 2) + + # draw text + text_surface = self.font.render(self.text, True, self.text_color) + + # show text with indentation + screen.blit(text_surface, (self.rect.x + 10, self.rect.y + 10)) + + def get_text(self): + return self.text From db64d956b3ae135caaf082914f54732f0ad0e673 Mon Sep 17 00:00:00 2001 From: Lukas Kammerhofer Date: Thu, 7 May 2026 21:17:12 +0200 Subject: [PATCH 20/21] map layout changes --- src/map.py | 59 +++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/src/map.py b/src/map.py index 651581d..c0881fa 100644 --- a/src/map.py +++ b/src/map.py @@ -2,7 +2,7 @@ import pygame # Fenstergröße und Tile Größe (Felder) tile_size = 30 -screen_w = 1800 +screen_w = 1900 screen_h = 900 # Farben für die einzelnen Tiles @@ -12,7 +12,8 @@ color_hall = (35, 65, 45) # dark green color_door = (40, 90, 110) # dark blue color_void = (10, 10, 15) # a little more black color_text = (220, 180, 210) # rose -color_border = (55, 35, 70) # dark violet +color_border = (55, 35, 70) +color_start = (255, 0, 0)# dark violet class Map: @@ -21,32 +22,36 @@ class Map: # Map wird mit "Tiles" (30x30 Feldern aufgebaut # W=Wall, R=Room, S=Start, H=Hall, D=Door self.map = [ - "WWWWWWWWWWWWWWWWWSSWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", - "WRRRRRRRRRRRRRRRWHHWRR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HHHHHHHHHHHHDD", + "WWHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHWW", + "WWHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHWW", + "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", + "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", ] # Raumbeschreibung in (Spalte, Zeile, Beschreibung) # gibt an wo der Raumname auf dem Bildschirm angezeigt wird self.room_decription = [ - (8, 3, "Room 102"), - (27, 3, "Room 103"), - (43, 3, "Room 105") + (7, 13, "Room 102"), + (32, 13, "Room 103"), + (49, 13, "Room 105") ] @@ -73,7 +78,7 @@ class Map: "R": color_room, "H": color_hall, "D": color_door, - "S": color_hall, + "S": color_start, } # äußere Schleife Zeile für Zeile @@ -108,8 +113,8 @@ class Map: column, row, text = self.room_decription[i] # die Tile-Koordinaten in Pixel umrechnen und addieren von 2, damit der Text nicht ganz am Rand klebt - px = column + tile_size - cam_x + 2 - py = row + tile_size - cam_y + 2 + px = column * tile_size - cam_x + 2 + py = row * tile_size - cam_y + 2 # Text-Bild mit fon.render() # True gibt eine glattere Schrift @@ -121,7 +126,7 @@ if __name__ == "__main__": pygame.init() screen = pygame.display.set_mode((screen_w, screen_h)) - font = pygame.font.SysFont("monospace", 12, bold=True) + font = pygame.font.SysFont("monospace", 26, bold=True) clock = pygame.time.Clock() my_map = Map() From 387a328b1ce59e1df645caaee4ce15fb8ae80634 Mon Sep 17 00:00:00 2001 From: Kevin Baumgartner Date: Thu, 7 May 2026 21:19:42 +0200 Subject: [PATCH 21/21] feat(text_input): add event handler function (mouse and keyboard input) --- src/text_input.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/text_input.py b/src/text_input.py index 6272f3b..64acc25 100644 --- a/src/text_input.py +++ b/src/text_input.py @@ -9,7 +9,7 @@ class TextInput: # input text self.text = "" - self.active = True + self.active = False # colors self.text_color = (255, 255, 255) @@ -18,8 +18,25 @@ class TextInput: self.background_color = (30, 30, 30) def handle_event(self, event): - # todo check keyboard input events - pass + # check if mouse click event on text input box + if event.type == pygame.MOUSEBUTTONDOWN: + if self.rect.collidepoint(event.pos): + self.active = True + else: + self.active = False + + # check for keyboard input + if event.type == pygame.KEYDOWN and self.active: + # enter will submit and exit input box + if event.key == pygame.K_RETURN: + self.active = False + + # backspace will delete last character + elif event.key == pygame.K_BACKSPACE: + self.text = self.text[:-1] + # other characters will be added to the string + else: + self.text += event.unicode def draw(self, screen): # draw background of input box