Compare commits

..

24 commits

Author SHA1 Message Date
Benjamin
ce420d52c6 Ende 11.11.26 2026-11-11 18:32:27 +01:00
Benjamin
99dc8c8a98 Assets angepasst 2026-11-11 18:01:38 +01:00
Benjamin
a97f46b127 Wieder so wie vorher 2026-11-11 17:54:46 +01:00
Benjamin
8b42ab04f1 funktioniert nicht 2026-11-11 17:46:48 +01:00
Benjamin
d3d80fc8f0 Aufgaben gemacht, aber die Kollision mit Bildern funktioniert nicht so gut 2026-11-04 19:50:15 +01:00
Benjamin
c8494dcab1 Hausaufgabe aufgeschrieben 2026-10-23 18:33:03 +02:00
Benjamin
3bc545d3c0 Player als Player eingefügt 2026-10-23 18:24:51 +02:00
Benjamin
02622ce4b8 Fertige Wand Renderung 2026-10-23 17:58:20 +02:00
Benjamin
64cb1fa862 Nächster Schritt fertig 2026-10-23 17:45:28 +02:00
Benjamin
d80e8391cb Wände angepasst: Konstruktor der Wall-Klasse geändert, um Spalten und Reihen zu verwenden, und die Wandpositionen im Spiel aktualisiert. 2026-10-23 17:43:02 +02:00
Benjamin
d7f2b54f3b Es funktioniert, aber das Spiel laggt seeeeeehr (Jay probier es mal selber aus. In Zoom sieht man es wahrscheinlich nicht) 2026-10-23 16:14:13 +02:00
Benjamin
01e925902a Assets und Klassen für das Spiel hinzugefügt: neue Texturen, Level- und Item-Klassen implementiert, sowie die Flashlight-Logik erstellt. 2026-10-16 18:31:55 +02:00
Benjamin
f41f872243 Item Fehler gefixt 2026-10-16 17:24:28 +02:00
Benjamin
b0b979d80b ASSETTTTTS GEHOOOOOOLT 2026-10-16 12:40:12 +02:00
Benjamin
f91d7a7fa1 ENDE: 09.10.2026 2026-10-09 18:32:12 +02:00
Benjamin
b2ae3d4ba7 Aufgabe gelöst 2026-10-09 18:04:58 +02:00
Benjamin
45d9d71310 Refactor Flashlight-Klasse: Lichtpunkte erstellen und Rendering-Logik aktualisieren 2026-10-09 17:35:17 +02:00
Benjamin
08004b8d3b create_light_points() in Flashlight Klasse gemacht und die Klasse umbenannt 2026-10-09 17:25:19 +02:00
Benjamin
30c3b2fe8d Assets freigegeben 2026-10-09 17:05:48 +02:00
Benjamin
8a5f4391b1 Fertige Hausaufgabe!!! (Mit dem Lösen eines Problems von der Woche davor) 2026-10-07 15:49:15 +02:00
Benjamin
d815755074 Füge Lichtsteuerung hinzu und aktualisiere Rendering-Logik 2026-10-02 18:32:13 +02:00
Benjamin
ac71ff12c7 Füge Asset-Ladefunktion hinzu und zeichne den Boden mit Game Assets 2026-10-02 18:28:01 +02:00
Benjamin
1de1af1e70 Der Sauberste Code 2026-10-02 17:22:08 +02:00
Benjamin
ac6018ff48 Test 2026-10-02 17:03:33 +02:00
1265 changed files with 1158 additions and 222 deletions

1
.gitignore vendored
View file

@ -221,4 +221,3 @@ __marimo__/
rechner.py
data/

Binary file not shown.

BIN
ZIPTE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

131
backup/game.py Normal file
View file

@ -0,0 +1,131 @@
import pygame
from scripts.constants import *
from scripts.flashlight import Flashlight
from scripts.level import Level
from scripts.player import Player
from scripts.utils import load_image
from scripts.wall import Wall
class Game:
def __init__(self):
# Pygame setup
pygame.init()
pygame.display.set_caption("School Game")
self.clock = pygame.Clock()
# Surfaces
self.screen: pygame.Surface = pygame.display.set_mode(
(SCREEN_WIDTH, SCREEN_HEIGHT)
)
# Pygame-Variablen
self.running: bool = True
self.dt: int = 0
# Spieler
self.player_pos = pygame.Vector2(
self.screen.get_width() / 2, self.screen.get_height() / 2
)
# Assets
self.assets = {
"floor_01": load_image("level/ground/floor_1.png"),
"plant_01": load_image("items/furniture/plants/plant.png"),
"wall": load_image("level/walls/wall_0.png"),
"player": load_image("entity/player/player.png"),
}
self.player = Player(self.player_pos, width=PLAYER_SIZE, height=PLAYER_SIZE, image=self.assets["player"])
self.flashlight_player = Flashlight(self, self.player)
self.level = Level(
game=self,
items=[],
walls=[
Wall(self, 0, 0, SCREEN_WIDTH//TILE_SIZE, 1),
Wall(self, 0, TILE_SIZE, 1, SCREEN_HEIGHT//TILE_SIZE),
Wall(
self, TILE_SIZE, SCREEN_HEIGHT - TILE_SIZE, SCREEN_WIDTH//TILE_SIZE, 1
),
Wall(self, SCREEN_WIDTH - TILE_SIZE, 0, 1, SCREEN_HEIGHT//TILE_SIZE),
Wall(self, 500, 500, 2, 2)
],
)
self.level_zustand: int = 0
@property
def walls(self):
return self.level.walls
@property
def items(self):
return self.level.items
def update(self) -> None:
# Ereignisse
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
self.running = False
if event.key == pygame.K_LSHIFT:
self.player.speed = 300
if event.key == pygame.K_q:
self.flashlight_player.light_state = (
not self.flashlight_player.light_state
)
if event.type == pygame.KEYUP and event.key == pygame.K_LSHIFT:
self.player.speed = 150
# Spielzustände aktualisieren
self.player.update(walls=self.walls, dt=self.dt)
self.flashlight_player.update()
for item in self.items:
item.update()
def render(self) -> None:
# Hintergrund
self.screen.fill((0, 0, 0, 0))
self.level.render(self.screen)
# 1. Zeichne 1 Tile -> []
# 2. Zeichne eine Reihe von Tiles -> [][][][][][]
# 3. Zeichne mehrere Reihen von Tiles
# -> [][][][][][]
# -> [][][][][][]
# -> [][][][][][]
# Licht
self.flashlight_player.render(self.screen)
for item in self.items:
item.render(self.screen)
# Spieler
self.player.render(self.screen)
# Surfaces aktualisieren
pygame.display.update()
def run(self) -> None:
while self.running:
self.dt: float = self.clock.tick(60) / 1000.0
self.update()
self.render()
game = Game()
game.run()
"""
Wie funktioniert Kollision mit Bildern?????????????????????????!!!!!!!!!!!!!!!!!!!!!!!!!!!
(Günter hat ein Tutorial)
"""

76
backup/player.py Normal file
View file

@ -0,0 +1,76 @@
import pygame
from pygame.math import Vector2
from scripts.constants import *
class Player:
def __init__(self, pos: pygame.Vector2, width, height, image: pygame.Surface=None):
self.pos: Vector2 = pos
self.width: float = width
self.height: float = height
self.speed = 150
self.image = image
self.mask = pygame.mask.from_surface(image)
self.rect = image.get_frect(center=(64, 64))
# self.rect = pygame.Rect(
# self.pos[0] - self.width / 2, self.pos[1] - self.height / 2, width, height
# )
def update(self, walls, dt):
keys = pygame.key.get_pressed()
direction = pygame.Vector2(
keys[pygame.K_d] - keys[pygame.K_a], keys[pygame.K_s] - keys[pygame.K_w]
)
if direction.length_squared() > 0:
direction = direction.normalize()
movement: pygame.Vector2 = direction * self.speed * dt
self.pos.x += movement.x
if self.pos.x - self.width / 2 < 0:
self.pos.x = self.width / 2
if self.pos.x + self.width / 2 > SCREEN_WIDTH:
self.pos.x = SCREEN_WIDTH - self.width / 2
self.rect.centerx = round(self.pos.x)
for wall in walls:
wall_rect = wall.get_rect()
if self.mask.overlap(pygame.mask.from_surface(wall.image), (0, 0)):
if movement.x > 0:
self.rect.right = wall_rect.left
elif movement.x < 0:
self.rect.left = wall_rect.right
self.pos.x = self.rect.centerx
self.pos.y += movement.y
if self.pos.y - self.height / 2 < 0:
self.pos.y = self.height / 2
if self.pos.y + self.height / 2 > SCREEN_HEIGHT:
self.pos.y = SCREEN_HEIGHT - self.height / 2
self.rect.centery = round(self.pos.y)
for wall in walls:
wall_rect = wall.get_rect()
offset = (int(self.rect.x) - wall_rect.x, int(self.rect.y) - wall_rect.y)
if self.mask.overlap(pygame.mask.from_surface(wall.image), offset):
if movement.y > 0:
self.rect.bottom = wall_rect.top
elif movement.y < 0:
self.rect.top = wall_rect.bottom
self.pos.y = self.rect.centery
def render(self, surface: pygame.Surface):
if not self.image:
pygame.draw.rect(surface, self.color, self.rect)
else:
surface.blit(
self.image,
(self.pos[0]-TILE_SIZE/2, self.pos[1]-TILE_SIZE/2-10, self.image.get_width(), self.image.get_height()),
)

35
backup/wall.py Normal file
View file

@ -0,0 +1,35 @@
import pygame
from scripts.constants import *
class Wall:
def __init__(self, game, x: float, y: float, cols: int, rows: int):
self.game = game
self.x = x
self.y = y
self.cols = cols
self.rows = rows
self.rect = pygame.Rect(x, y, cols*TILE_SIZE, rows*TILE_SIZE)
self.drawed_rect = None
self.grid: list[list[pygame.Rect]] = []
self.image = self.game.assets["wall"]
for row in range(self.rows): # rows
current_row = []
for col in range(self.cols): # cols
current_row.append(pygame.Rect(self.x+col*TILE_SIZE, self.y+row*TILE_SIZE, col*TILE_SIZE, row*TILE_SIZE))
self.grid.append(current_row)
def update(self):
pass
def render(self, surface: pygame.Surface):
for row in self.grid:
for wall_rect in row:
surface.blit(self.image, wall_rect)
def get_rect(self) -> pygame.Rect:
return self.rect

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Some files were not shown because too many files have changed in this diff Show more