diff options
-rwxr-xr-x | cameltris.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/cameltris.py b/cameltris.py index 1458a99..0b0aa7e 100755 --- a/cameltris.py +++ b/cameltris.py @@ -349,6 +349,8 @@ lines_burnt = 0 das = 0 +pressing_down_countdown = None + while True: piece_drop_frames += 1 @@ -371,11 +373,14 @@ while True: rotate_piece_counter_clockwise() if event.key in (pygame.K_DOWN, pygame.K_j): piece_drop_frames = 0 - das = 0 + pressing_down_countdown = 3 try: move_piece_down() except WouldCollide: stick_piece() + elif event.type == pygame.KEYUP: + if event.key in (pygame.K_DOWN, pygame.K_j): + pressing_down_countdown = None das += 1 if das == 16: @@ -385,13 +390,17 @@ while True: move_piece_right() if pressed_keys[pygame.K_LEFT] or pressed_keys[pygame.K_h]: move_piece_left() - if pressed_keys[pygame.K_DOWN] or pressed_keys[pygame.K_j]: - try: - move_piece_down() - except WouldCollide: - stick_piece() das = 10 + if pressing_down_countdown == 0: + try: + move_piece_down() + except WouldCollide: + stick_piece() + pressing_down_countdown = 2 + elif pressing_down_countdown is not None: + pressing_down_countdown -= 1 + if piece_drop_frames >= frames_per_gridcell[level - 1]: piece_drop_frames = 0 try: |