ENDE: 18.09.2026
This commit is contained in:
parent
f71dae0af4
commit
0476dadfa4
1 changed files with 14 additions and 11 deletions
25
game.py
25
game.py
|
|
@ -175,9 +175,15 @@ class Player:
|
|||
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/2:
|
||||
self.pos.x = SCREEN_WIDTH/2 - self.width/2
|
||||
# self.pos += movement
|
||||
|
||||
|
||||
|
|
@ -194,16 +200,16 @@ class Player:
|
|||
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
for wall in walls:
|
||||
|
|
@ -216,11 +222,8 @@ class Player:
|
|||
|
||||
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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue