Jump compensation bug fixed

master
kaqu 2 years ago
parent 09bbbeca9c
commit d7a2b2f9ee
  1. 20
      game_objects/pong_object.py

@ -47,20 +47,26 @@ class PongObject:
sum_y = self.y + self.delta_y
# Left/right: Out-of-game area check
if sum_x < pgc.GAMEAREA_MIN_X: # Player #1 side
if sum_x < pgc.GAMEAREA_MIN_X: # Player #1 side
if (sum_y < player1.y) or (sum_y > (player1.y + player1.h)): # Out of player range?
bChanged = -1 # Miss left
else: # Correct player #1 'passed'
sum_x = pgc.GAMEAREA_MIN_X + player1.w
self.delta_x = -self.delta_x
self.playsound = pgc.PLAYERCONTACTSOUND
if self.x > (player1.x + player1.w): # Only to suppress 'jump over'
sum_x = player1.x + player1.w
self.delta_x = -self.delta_x
self.playsound = pgc.PLAYERCONTACTSOUND
else:
bChanged = -1 # Miss left (as well)
elif (sum_x + self.w) > pgc.GAMEAREA_MAX_X: # Player #2 side
if (sum_y < player2.y) or (sum_y > (player2.y + player2.h)): # Out of player range?
bChanged = 1 # Miss right
else: # Correct player #2 'passed' ...
sum_x = pgc.GAMEAREA_MAX_X - player2.w
self.delta_x = -self.delta_x
self.playsound = pgc.PLAYERCONTACTSOUND
if self.x < player2.x: # Only to suppress 'jump over'
sum_x = player2.x - self.w
self.delta_x = -self.delta_x
self.playsound = pgc.PLAYERCONTACTSOUND
else:
bChanged = 1 # Miss right (as well)
# Wall contact check
if sum_y < pgc.GAMEAREA_MIN_Y:

Loading…
Cancel
Save