Move block working. /JL

This commit is contained in:
2025-04-22 20:23:05 +02:00
parent d5f9188865
commit 2e3460dca5
4 changed files with 19 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ from dropzone import DropZone
from dropnext import DropNext
from hud import Hud
__version__ = "0.0.2"
__version__ = "0.0.3"
# Constants
HAT_REPEAT_DELAY = 0 # milliseconds before first repeat
@@ -21,6 +21,9 @@ class Tetris:
while self.running:
self.main_loop()
if self.joysticks:
self.joysticks[self.joy.get_instance_id()].controllers[0].close()
pygame.quit()
@@ -105,14 +108,15 @@ class Tetris:
self.current.direction = enums.BrickDirection.Left
self.current.move_left()
self.dropzone.draw_brick(self.current.brick, self.current.location)
case pygame.K_UP:
case pygame.K_SPACE:
if self.current.direction == enums.BrickDirection.Dropped:
break
self.current.rotate()
case pygame.K_DOWN:
case pygame.K_RETURN:
if self.current.direction == enums.BrickDirection.Dropped:
break
self.current.drop()
case pygame.JOYHATMOTION:
self.hat_direction = event.value
self.hat_x, self.hat_y = self.hat_direction
@@ -129,11 +133,13 @@ class Tetris:
break
self.current.direction = enums.BrickDirection.Left
self.current.move_left()
elif self.hat_y == 1:
if self.current.direction == enums.BrickDirection.Dropped:
break
self.current.rotate()
elif self.hat_y == -1:
case pygame.JOYBUTTONDOWN:
if event.button == 2:
if self.current.direction == enums.BrickDirection.Dropped:
break
self.current.rotate()
elif event.button == 0:
if self.current.direction == enums.BrickDirection.Dropped:
break
self.current.drop()