Fix hard drop issues on mobile: prevent unwanted rotations when 3D effects are off and fix non-working hard drops when 3D effects are on

This commit is contained in:
cmclark00 2025-03-25 19:03:13 -04:00
parent c29e868320
commit 9d3a190888

View file

@ -670,6 +670,11 @@ class Piece {
// Hard drop
hardDrop() {
// Skip if we're in the middle of an animation already
if (this.rotationTransition || this.showCompletionEffect) {
return;
}
// Cancel any ongoing rotations or animations
this.rotationTransition = false;
this.showCompletionEffect = false;
@ -677,6 +682,14 @@ class Piece {
this.rotationAngleY = 0;
this.rotationAngleZ = 0;
// Clear rotation state completely
this.rotationDirection = null;
this.targetTetromino = null;
this.targetPattern = undefined;
this.targetKick = undefined;
this.originalTetromino = null;
this.rotationProgress = 0;
// Clear previous position
this.undraw();
clearPreviousPiecePosition();
@ -2188,7 +2201,10 @@ function handleControllerAction(action) {
p.mirrorVertical();
break;
case 'hardDrop':
// Only perform hard drop if not in the middle of an animation
if (!p.rotationTransition && !p.showCompletionEffect) {
p.hardDrop();
}
break;
case 'pause':
togglePause();
@ -2409,13 +2425,13 @@ function handleTouchEnd(event) {
const touchX = touch.clientX;
const touchY = touch.clientY;
// Skip if we're in the middle of a rotation animation
if (p.rotationTransition || p.showCompletionEffect) {
// If a double tap is in progress, prevent further processing
if (doubleTapInProgress) {
return;
}
// If a double tap is in progress, prevent further processing
if (doubleTapInProgress) {
// Skip if we're in the middle of a rotation animation
if (p.rotationTransition || p.showCompletionEffect) {
return;
}
@ -2434,8 +2450,10 @@ function handleTouchEnd(event) {
// This is a double tap - perform hard drop
doubleTapInProgress = true;
// Perform the hard drop
// Perform the hard drop if not in an animation
if (!p.rotationTransition && !p.showCompletionEffect) {
p.hardDrop();
}
// Reset tap tracking
tapCount = 0;