feat: improve touch controls - increase tap sensitivity for rotation and make hard drop more distinct

This commit is contained in:
cmclark00 2025-03-30 15:45:19 -04:00
parent 53c46c9864
commit e23d33e2e2

View file

@ -150,11 +150,12 @@ class GameView @JvmOverloads constructor(
private var lastHoldTime = 0L // Track when the last hold occurred
private val holdCooldown = 250L // Minimum time between holds
private var lockedDirection: Direction? = null // Track the locked movement direction
private val minMovementThreshold = 0.5f // Reduced from 0.75f for more sensitive movement
private val directionLockThreshold = 1.5f // Reduced from 2.5f to make direction locking less aggressive
private val minMovementThreshold = 0.3f // Reduced from 0.5f for more sensitive horizontal movement
private val directionLockThreshold = 1.0f // Reduced from 1.5f to make direction locking less aggressive
private val isStrictDirectionLock = true // Re-enabled strict direction locking to prevent diagonal inputs
private val minHardDropDistance = 1.5f // Minimum distance (in blocks) for hard drop gesture
private val minHardDropDistance = 2.5f // Increased from 1.5f to require more deliberate hard drops
private val minHoldDistance = 2.0f // Minimum distance (in blocks) for hold gesture
private val maxSoftDropDistance = 1.5f // Maximum distance for soft drop before considering hard drop
// Block skin
private var currentBlockSkin: String = "block_skin_1"
@ -892,9 +893,10 @@ class GameView @JvmOverloads constructor(
invalidate()
}
}
// Check for hard drop
// Check for hard drop (must be faster and longer than soft drop)
else if (deltaY > blockSize * minHardDropDistance &&
abs(deltaX) / abs(deltaY) < 0.5f) {
abs(deltaX) / abs(deltaY) < 0.5f &&
(deltaY / moveTime) * 1000 > minSwipeVelocity) {
if (currentTime - lastHardDropTime < hardDropCooldown) {
Log.d(TAG, "Hard drop blocked by cooldown - time since last: ${currentTime - lastHardDropTime}ms, cooldown: ${hardDropCooldown}ms")
} else {
@ -905,10 +907,17 @@ class GameView @JvmOverloads constructor(
invalidate()
}
}
// Check for soft drop (slower and shorter than hard drop)
else if (deltaY > blockSize * minMovementThreshold &&
deltaY < blockSize * maxSoftDropDistance &&
(deltaY / moveTime) * 1000 < minSwipeVelocity) {
gameBoard.softDrop()
invalidate()
}
// Check for rotation (quick tap with minimal movement)
else if (moveTime < minTapTime &&
abs(deltaY) < maxTapMovement &&
abs(deltaX) < maxTapMovement) {
else if (moveTime < minTapTime * 1.5 && // Increased from 1.0 to 1.5 for more lenient timing
abs(deltaY) < maxTapMovement * 1.5 && // Increased from 1.0 to 1.5 for more lenient movement
abs(deltaX) < maxTapMovement * 1.5) { // Increased from 1.0 to 1.5 for more lenient movement
if (currentTime - lastRotationTime >= rotationCooldown) {
Log.d(TAG, "Rotation detected - moveTime: $moveTime, deltaX: $deltaX, deltaY: $deltaY")
gameBoard.rotate()