Skip to content

Commit

Permalink
OOB fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AvaAvarai committed Jul 31, 2023
1 parent 5f45812 commit cf90a44
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ def start(self):
if self.ball_pos.colliderect(pygame.rect.Rect(0, UI_HEIGHT + 4, WIN_WIDTH, 1)):
self.ball_dir[1] *= -1

if self.ball_pos.centerx < 0:
self.ball_pos.move(0, self.ball_pos.centery)
elif self.ball_pos.centerx > WIN_WIDTH:
self.ball_pos.move(WIN_WIDTH, self.ball_pos.centery)

if self.ball_pos.centery > WIN_HEIGHT:
self.ball_pos.move(self.ball_pos.centerx, WIN_HEIGHT)

# --- BALL\PLAYER COLLIDE ---
if self.ball_pos.colliderect(self.player_pos):
self.ball_dir[1] = -1
Expand Down

0 comments on commit cf90a44

Please sign in to comment.