Pad responsiveness improved

master
kaqu 2 years ago
parent e693bf07b8
commit d1dad535dd
  1. 10
      game_objects/pong_game.py
  2. 16
      game_objects/pong_player.py

@ -209,11 +209,17 @@ class PongGame:
# TODO: Check horizontal clear, invert X?!
if rc == -1: # Player #2: +1
player2.score = player2.score + 1
ball.reinit(10 + (random() - 0.5) * 4, (random() - 0.5) * 10)
if pgv.bIsLocal == True:
ball.reinit(10 + (random() - 0.5) * 4, (random() - 0.5) * 10)
else:
ball.reinit(20 + (random() - 0.5) * 8, (random() - 0.5) * 10)
self.playsound = pgc.PLAYERMISSSOUND
else: # Player #1: +1
player1.score = player1.score + 1
ball.reinit(-(10 + (random() - 0.5) * 4), (random() - 0.5) * 10)
if pgv.bIsLocal == True:
ball.reinit(-(10 + (random() - 0.5) * 4), (random() - 0.5) * 10)
else:
ball.reinit(-(20 + (random() - 0.5) * 8), (random() - 0.5) * 10)
self.playsound = pgc.PLAYERMISSSOUND
if pgv.bIsLocal == False:
player1.clear_UDP_queue() # Dry up queues ...

@ -163,16 +163,16 @@ class PongPlayer:
elif type_value == 3: # EV_ABS
if code_value == 0: # ABS_X
if value == 0:
self.delta_x = self.delta_x - 1
self.delta_x = self.delta_x - 2
elif value == 255:
self.delta_x = self.delta_x + 1
self.delta_x = self.delta_x + 2
else: # 127/Neutral
self.delta_x = 0
else: # ABS_Y
if value == 0:
self.delta_y = self.delta_y - 1
self.delta_y = self.delta_y - 2
elif value == 255:
self.delta_y = self.delta_y + 1
self.delta_y = self.delta_y + 2
else: # 127/Neutral
self.delta_y = 0
bChanged = True
@ -186,7 +186,13 @@ class PongPlayer:
bChanged = False
try:
if self.dev or self.bIsBot:
if self.dev or self.bIsBot:
# Keep up the speed!
if self.delta_y != 0:
self.delta_y = self.delta_y * 1.05
if self.delta_x != 0:
self.delta_x = self.delta_x * 1.05
if self.dev: # USB gamepad device avail.
for e in self.dev.events():
bChanged = bChanged or self.eval_data(e.type.value, e.value, e.code.value)

Loading…
Cancel
Save