diff --git a/src/game/screens/tetris.py b/src/game/screens/tetris.py index a902cb0..9a683bf 100644 --- a/src/game/screens/tetris.py +++ b/src/game/screens/tetris.py @@ -285,6 +285,7 @@ class Tetris(BaseScreen): Timer(self.initial_block_speed, True, self.move_down), Timer(CONFIG.game.movment_delay), Timer(CONFIG.game.rotation_delay), + Timer(CONFIG.game.drop_delay), ) self.timers.vertical.activate() @@ -293,6 +294,7 @@ class Tetris(BaseScreen): self.initial_block_speed = CONFIG.game.initial_speed self.increased_block_speed = self.initial_block_speed * 0.4 self.down_pressed = False + self.drop_pressed = False self.level: int = 1 self.score: int = 0 self.lines: int = 0 @@ -351,6 +353,7 @@ class Tetris(BaseScreen): counter_clockwise_keys = ( keys[pygame.K_e] or keys[pygame.K_i] or keys[pygame.K_LEFT] ) + if not self.timers.rotation.active: if clockwise_keys: self.rotate() @@ -375,8 +378,9 @@ class Tetris(BaseScreen): """Handle the drop key [K_SPACE].""" drop_keys = keys[pygame.K_SPACE] - if drop_keys: + if not self.timers.drop.active and drop_keys: self.drop() + self.timers.drop.activate() def _reset_game_state(self) -> None: """Reset the game state.""" diff --git a/src/game/timer.py b/src/game/timer.py index ec6dcde..a64cdd5 100644 --- a/src/game/timer.py +++ b/src/game/timer.py @@ -63,8 +63,10 @@ class Timers(NamedTuple): vertical: Timer for vertical movement. horizontal: Timer for horizontal movement. rotation: Timer for rotation. + drop: Timer for dropping. """ vertical: Timer horizontal: Timer rotation: Timer + drop: Timer diff --git a/src/utils/config.py b/src/utils/config.py index e606eaa..ef3bbb0 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -21,9 +21,10 @@ class Game: size: Size = Size(columns * cell.width, rows * cell.width) pos: Vec2 = Vec2(padding, padding) offset: Vec2 = Vec2(columns // 2, -1) - initial_speed: float | int = 200 - movment_delay: int = 200 + initial_speed: float | int = 300 + movment_delay: int = 100 rotation_delay: int = 200 + drop_delay: int = 200 score: dict[int, int] = {1: 40, 2: 100, 3: 300, 4: 1200}