Block falling working. /JL

This commit is contained in:
2025-04-22 20:59:52 +02:00
parent 2e3460dca5
commit 9696719067
3 changed files with 20 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ from dropzone import DropZone
from dropnext import DropNext
from hud import Hud
__version__ = "0.0.3"
__version__ = "0.0.4"
# Constants
HAT_REPEAT_DELAY = 0 # milliseconds before first repeat
@@ -51,7 +51,13 @@ class Tetris:
self.clock = pygame.time.Clock()
self.rumble_timer = pygame.time.get_ticks()
self.fall_speed = 1000 # in milliseconds
self.fall_timer = pygame.USEREVENT + 1
pygame.time.set_timer(self.fall_timer, self.get_fall_speed(self.hud.level))
def get_fall_speed(self, level):
return max(100, 1000 - (level - 1) * 100)
def main_loop(self):
if self.joysticks:
if pygame.time.get_ticks() - self.rumble_timer > RUMBLE_TIMEOUT:
@@ -166,6 +172,9 @@ class Tetris:
break
self.current.drop()
case self.fall_timer:
self.current.update()
# Handle hotplugging
case pygame.JOYDEVICEADDED:
# This event will be generated when the program starts for every