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