aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Leah Alpert <lalpert@mit.edu>2011-08-28 23:33:55 -0700
committerGravatar Leah Alpert <lalpert@mit.edu>2011-08-28 23:33:55 -0700
commit2dc75afd2c6b01a9d9aa419234157330d8eb172f (patch)
tree9a8eb34e4de36e3bc2a833bb35a82c7aac723cc6
parenta62926dd1e304cd75066811425de108f340926f6 (diff)
Reset input queue at start of each game
-rw-r--r--ddrinput.py6
-rw-r--r--tetris.py1
2 files changed, 6 insertions, 1 deletions
diff --git a/ddrinput.py b/ddrinput.py
index a1bf482..19966d8 100644
--- a/ddrinput.py
+++ b/ddrinput.py
@@ -1,4 +1,5 @@
import pygame
+
JOY_EVENT = 7
KEY_EVENT = 2
X = 0
@@ -45,7 +46,10 @@ class DdrInput(object):
for i in range(totaljoy):
m = pygame.joystick.Joystick(i)
m.init()
-
+
+ def reset(self):
+ pygame.event.clear()
+
def poll(self):
"""
Returns a tuple of player index (0 or 1) and move,
diff --git a/tetris.py b/tetris.py
index fd67ae2..64b3eed 100644
--- a/tetris.py
+++ b/tetris.py
@@ -217,6 +217,7 @@ class TetrisGame(object):
self.board_animation(0,"up_arrow")
self.board_animation(1,"up_arrow")
self.start_time = None
+ self.input.reset()
self.update_gui()
self.handle_input() #this calls all other functions, such as add_player, start_game