diff --git a/app/src/main/java/com/mintris/MainActivity.kt b/app/src/main/java/com/mintris/MainActivity.kt
index 7aa7bb9..253f8b9 100644
--- a/app/src/main/java/com/mintris/MainActivity.kt
+++ b/app/src/main/java/com/mintris/MainActivity.kt
@@ -93,6 +93,16 @@ class MainActivity : AppCompatActivity() {
themeSelector = binding.themeSelector
blockSkinSelector = binding.blockSkinSelector
+ // Set up touch event forwarding
+ binding.touchInterceptor?.setOnTouchListener { _, event ->
+ if (gameView.visibility == View.VISIBLE && !gameView.isPaused && !gameView.isGameOver()) {
+ gameView.onTouchEvent(event)
+ true
+ } else {
+ false
+ }
+ }
+
// Set up progression screen
progressionScreen = binding.progressionScreen
progressionScreen.visibility = View.GONE
diff --git a/app/src/main/java/com/mintris/game/GameView.kt b/app/src/main/java/com/mintris/game/GameView.kt
index f5043f1..05308d8 100644
--- a/app/src/main/java/com/mintris/game/GameView.kt
+++ b/app/src/main/java/com/mintris/game/GameView.kt
@@ -1019,16 +1019,6 @@ class GameView @JvmOverloads constructor(
return true
}
- // Define the game board boundaries
- val boardRight = boardLeft + (gameBoard.width * blockSize)
- val boardBottom = boardTop + (gameBoard.height * blockSize)
-
- // Determine if touch is on left side, right side, or within board area
- val isLeftSide = event.x < boardLeft
- val isRightSide = event.x > boardRight
- val isWithinBoard = event.x >= boardLeft && event.x <= boardRight &&
- event.y >= boardTop && event.y <= boardBottom
-
when (event.action) {
MotionEvent.ACTION_DOWN -> {
startX = event.x
@@ -1061,81 +1051,36 @@ class GameView @JvmOverloads constructor(
}
}
- // Special handling for landscape mode - side controls
- if (isLeftSide) {
- // Left side controls - move left
- if (deltaY < -blockSize * minMovementThreshold) {
- // Swipe up on left side - rotate
- if (currentTime - lastRotationTime >= rotationCooldown) {
- gameBoard.rotate()
- lastRotationTime = currentTime
- gameHaptics?.vibrateForPieceMove()
+ // Handle movement based on locked direction
+ when (lockedDirection) {
+ Direction.HORIZONTAL -> {
+ if (abs(deltaX) > blockSize * minMovementThreshold) {
+ if (deltaX > 0) {
+ gameBoard.moveRight()
+ } else {
+ gameBoard.moveLeft()
+ }
+ lastTouchX = event.x
+ if (currentTime - lastMoveTime >= moveCooldown) {
+ gameHaptics?.vibrateForPieceMove()
+ lastMoveTime = currentTime
+ }
invalidate()
}
- } else if (deltaY > blockSize * minMovementThreshold) {
- // Swipe down on left side - move left
- gameBoard.moveLeft()
- lastTouchY = event.y
- if (currentTime - lastMoveTime >= moveCooldown) {
- gameHaptics?.vibrateForPieceMove()
- lastMoveTime = currentTime
- }
- invalidate()
}
- } else if (isRightSide) {
- // Right side controls - move right
- if (deltaY < -blockSize * minMovementThreshold) {
- // Swipe up on right side - hold piece
- if (currentTime - lastHoldTime >= holdCooldown) {
- gameBoard.holdPiece()
- lastHoldTime = currentTime
- gameHaptics?.vibrateForPieceMove()
+ Direction.VERTICAL -> {
+ if (deltaY > blockSize * minMovementThreshold) {
+ gameBoard.softDrop()
+ lastTouchY = event.y
+ if (currentTime - lastMoveTime >= moveCooldown) {
+ gameHaptics?.vibrateForPieceMove()
+ lastMoveTime = currentTime
+ }
invalidate()
}
- } else if (deltaY > blockSize * minMovementThreshold) {
- // Swipe down on right side - move right
- gameBoard.moveRight()
- lastTouchY = event.y
- if (currentTime - lastMoveTime >= moveCooldown) {
- gameHaptics?.vibrateForPieceMove()
- lastMoveTime = currentTime
- }
- invalidate()
}
- }
- // Standard touch controls for main board area or portrait mode
- else {
- // Handle movement based on locked direction
- when (lockedDirection) {
- Direction.HORIZONTAL -> {
- if (abs(deltaX) > blockSize * minMovementThreshold) {
- if (deltaX > 0) {
- gameBoard.moveRight()
- } else {
- gameBoard.moveLeft()
- }
- lastTouchX = event.x
- if (currentTime - lastMoveTime >= moveCooldown) {
- gameHaptics?.vibrateForPieceMove()
- lastMoveTime = currentTime
- }
- invalidate()
- }
- }
- Direction.VERTICAL -> {
- if (deltaY > blockSize * minMovementThreshold) {
- gameBoard.softDrop()
- lastTouchY = event.y
- if (currentTime - lastMoveTime >= moveCooldown) {
- gameHaptics?.vibrateForPieceMove()
- lastMoveTime = currentTime
- }
- invalidate()
- }
- }
- null -> {
- // No direction lock yet, don't process movement
- }
+ null -> {
+ // No direction lock yet, don't process movement
}
}
}
@@ -1145,23 +1090,12 @@ class GameView @JvmOverloads constructor(
val deltaY = event.y - startY
val moveTime = currentTime - lastTapTime
- // Special handling for taps on game board or sides
+ // Handle taps for rotation
if (moveTime < minTapTime * 1.5 &&
abs(deltaY) < maxTapMovement * 1.5 &&
abs(deltaX) < maxTapMovement * 1.5) {
- if (isLeftSide) {
- // Tap on left side - move left
- gameBoard.moveLeft()
- gameHaptics?.vibrateForPieceMove()
- invalidate()
- } else if (isRightSide) {
- // Tap on right side - move right
- gameBoard.moveRight()
- gameHaptics?.vibrateForPieceMove()
- invalidate()
- } else if (isWithinBoard && currentTime - lastRotationTime >= rotationCooldown) {
- // Tap on board - rotate
+ if (currentTime - lastRotationTime >= rotationCooldown) {
gameBoard.rotate()
lastRotationTime = currentTime
gameHaptics?.vibrateForPieceMove()
@@ -1170,15 +1104,11 @@ class GameView @JvmOverloads constructor(
return true
}
- // Long swipe handling for hard drops and holds
+ // Handle gestures
// Check for hold gesture (swipe up)
if (deltaY < -blockSize * minHoldDistance &&
abs(deltaX) / abs(deltaY) < 0.5f) {
- if (currentTime - lastHoldTime < holdCooldown) {
- Log.d(TAG, "Hold blocked by cooldown - time since last: ${currentTime - lastHoldTime}ms, cooldown: ${holdCooldown}ms")
- } else {
- // Process the hold
- Log.d(TAG, "Hold detected - deltaY: $deltaY, ratio: ${abs(deltaX) / abs(deltaY)}")
+ if (currentTime - lastHoldTime >= holdCooldown) {
gameBoard.holdPiece()
lastHoldTime = currentTime
gameHaptics?.vibrateForPieceMove()
@@ -1189,11 +1119,7 @@ class GameView @JvmOverloads constructor(
else if (deltaY > blockSize * minHardDropDistance &&
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 {
- // Process the hard drop
- Log.d(TAG, "Hard drop detected - deltaY: $deltaY, velocity: ${(deltaY / moveTime) * 1000}, ratio: ${abs(deltaX) / abs(deltaY)}")
+ if (currentTime - lastHardDropTime >= hardDropCooldown) {
gameBoard.hardDrop()
lastHardDropTime = currentTime
invalidate()
diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml
index 20ad154..0e03b36 100644
--- a/app/src/main/res/layout-land/activity_main.xml
+++ b/app/src/main/res/layout-land/activity_main.xml
@@ -8,16 +8,24 @@
android:fitsSystemWindows="true"
tools:context=".MainActivity">
+
+
+
+ android:background="@drawable/glow_border"
+ android:clickable="false"
+ android:focusable="false" />
-
+
+ app:layout_constraintWidth_percent="0.25"
+ android:clickable="false"
+ android:focusable="false"
+ android:elevation="1dp">
-
+
+ app:layout_constraintWidth_percent="0.25"
+ android:clickable="false"
+ android:focusable="false"
+ android:elevation="1dp">