diff --git a/tetri5/entity.py b/tetri5/entity.py index e9438b8..4dcac75 100644 --- a/tetri5/entity.py +++ b/tetri5/entity.py @@ -114,7 +114,7 @@ class Piece(Entity): self._applying_gravity = not self._applying_set # handle rotation, left and right movement - if Controller.key_down(pygame.K_SPACE): + if Controller.key_down(pygame.K_UP): self.rotate() if well and self.collide(well) or stack and self.collide(stack): self.revert() @@ -141,6 +141,12 @@ class Piece(Entity): self._gravity_time = gravity_time - (level * gravity_increase) self._set_time = set_time + # handle hard drop + if Controller.key_down(pygame.K_SPACE): + self._points = self._get_ghost_piece_points(well, stack) + self._add_to_stack(stack, clear_current_piece) + + def draw(self, surface: pygame.Surface, well: Well = None, stack: "Stack" = None) -> None: # ghost piece if well and stack: @@ -225,13 +231,16 @@ class Piece(Entity): if self._current_set_time >= self._set_time: self._current_set_time = 0 if self._entity_is_below(well) or self._entity_is_below(stack): - SoundManager.play_piece_set_sfx() - stack.add_piece(self) - clear_current_piece() + self._add_to_stack(stack, clear_current_piece) else: return False return True + def _add_to_stack(self, stack: "Stack", clear_current_piece: FunctionType) -> None: + SoundManager.play_piece_set_sfx() + stack.add_piece(self) + clear_current_piece() + def _mimic_move(self, vector: Tuple) -> List: mimic_points = copy.deepcopy(self._points)