ENDE: 18.09.2026

This commit is contained in:
Benjamin 2026-09-18 18:37:17 +02:00
parent f71dae0af4
commit 0476dadfa4

25
game.py
View file

@ -175,9 +175,15 @@ class Player:
movement: pygame.Vector2 = direction * self.speed * dt movement: pygame.Vector2 = direction * self.speed * dt
self.pos.x += movement.x 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/2:
self.pos.x = SCREEN_WIDTH/2 - self.width/2
# self.pos += movement # self.pos += movement
@ -194,16 +200,16 @@ class Player:
self.pos.x = self.rect.centerx self.pos.x = self.rect.centerx
# if self.pos.x < self.player_rect.width/2 or self.pos.x + self.player_rect.width > SCREEN_WIDTH:
# self.pos.x = old_position_x
if self.pos.x - self.rect.width/2 < 0:
self.pos.x = self.rect.width/2
if self.pos.x + self.width/2 > SCREEN_WIDTH/2:
self.pos.x = SCREEN_WIDTH/2 - self.width/2
self.pos.y += movement.y 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/2:
self.pos.y = SCREEN_HEIGHT/2 - self.height/2
self.rect.centery = round(self.pos.y) self.rect.centery = round(self.pos.y)
for wall in walls: for wall in walls:
@ -216,11 +222,8 @@ class Player:
self.pos.y = self.rect.centery self.pos.y = self.rect.centery
if self.pos.y - self.rect.height/2 < 0:
self.pos.y = self.rect.height/2
if self.pos.y + self.rect.height/2 > SCREEN_HEIGHT/2:
self.pos.y = SCREEN_HEIGHT/2 - self.rect.height/2
def render(self, surface): def render(self, surface):