Reset last_event exactly on a drop or fall. #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The check for last event is used in two places. Firstly to check when we should repeat a soft drop if DOWN is held. Secondly to check when the block should stop being slidable and stick to the floor. In both cases, the exact condition should be changed to be that the block either fell itself or was dropped (either hard or soft). Currently the timer resets each time a key is pressed.
The soft drop should repeat if it has been enough time since the previous soft drop. Moving the block to the left or right (which can be done while DOWN is held) should not affect how fast the soft drops repeat. Therefore the time should not be reset on LEFT, RIGHT, ROTATE, etc. Resetting the timer on falls just means that the block will not occasionally "double drop" when a fall and a soft drop coincide. Resetting the timer on hard drops has no effect since after a hard drop there is no longer a possibility to soft drop.
When a block hits the floor, it is possible that it hasnt been actively moved for a while, but has been left to fall, with the player getting ready to "slide" it as soon as it hits the floor. If we do not reset the "last_event" timer for falls, then the block could instantly stick, because it has already been enough time since the last player action. Resetting the timer every time the block falls on its own avoids this. On the other hand, resetting the timer for each left or right movement means that a player can slide the block for an indefinite amount of time after it hits the floor, as long as they press the movement keys frequently enough, since each movement will reset the timer. For the same reason, DOWN presses should not reset the time unless they lead to an actual downward movement. These changes mean that the sliding time starts exactly when the block hits the floor.