diff --git a/requirements.txt b/requirements.txt index 0eda428..63f1bc3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ pygame==2.6.1 -pygamecontrols==0.1.11 +pygamecontrols==0.1.13 diff --git a/tetris.py b/tetris.py index 04bc4d4..4f10f48 100644 --- a/tetris.py +++ b/tetris.py @@ -10,7 +10,7 @@ from dropzone import DropZone from dropnext import DropNext from hud import Hud -__version__ = "0.1.2" +__version__ = "0.1.3" # Constants HAT_REPEAT_DELAY = 0 # milliseconds before first repeat @@ -144,6 +144,18 @@ class Tetris: case pygame.JOYBUTTONDOWN: match event.button: + case self.left_button: + if self.current.direction == enums.BrickDirection.Dropped: + break + self.current.direction = enums.BrickDirection.Left + self.current.move_left() + self.dropzone.draw_brick(self.current.brick, self.current.location) + case self.right_button: + if self.current.direction == enums.BrickDirection.Dropped: + break + self.current.direction = enums.BrickDirection.Right + self.current.move_right() + self.dropzone.draw_brick(self.current.brick, self.current.location) case self.rotate_button: if self.current.direction == enums.BrickDirection.Dropped: break @@ -201,8 +213,13 @@ class Tetris: elif "A button" in self.joysticks[self.joy.get_instance_id()].controllers[0].mapping: self.drop_button = self.joysticks[self.joy.get_instance_id()].controllers[0].mapping["A button"] print(f"Drop button :{self.drop_button}") - - + + if "left button" in self.joysticks[self.joy.get_instance_id()].controllers[0].mapping: + self.left_button = self.joysticks[self.joy.get_instance_id()].controllers[0].mapping["left button"] + + if "right button" in self.joysticks[self.joy.get_instance_id()].controllers[0].mapping: + self.right_button = self.joysticks[self.joy.get_instance_id()].controllers[0].mapping["right button"] + case pygame.JOYDEVICEREMOVED: del self.joysticks[event.instance_id] print(f"Joystick {event.instance_id} disconnected")