diff --git a/app/src/main/java/com/mintris/game/GameView.kt b/app/src/main/java/com/mintris/game/GameView.kt index 95d4822..7f323be 100644 --- a/app/src/main/java/com/mintris/game/GameView.kt +++ b/app/src/main/java/com/mintris/game/GameView.kt @@ -251,8 +251,8 @@ class GameView @JvmOverloads constructor( return } - // Move the current tetromino down automatically - gameBoard.moveDown() + // Update the game state + gameBoard.update() // Update UI with current game state onGameStateChanged?.invoke(gameBoard.score, gameBoard.level, gameBoard.lines) @@ -653,7 +653,7 @@ class GameView @JvmOverloads constructor( } Direction.VERTICAL -> { if (deltaY > blockSize * minMovementThreshold) { - gameBoard.moveDown() + gameBoard.softDrop() lastTouchY = event.y if (currentTime - lastMoveTime >= moveCooldown) { gameHaptics?.vibrateForPieceMove() diff --git a/app/src/main/java/com/mintris/model/GameBoard.kt b/app/src/main/java/com/mintris/model/GameBoard.kt index b72921b..d871e4b 100644 --- a/app/src/main/java/com/mintris/model/GameBoard.kt +++ b/app/src/main/java/com/mintris/model/GameBoard.kt @@ -38,6 +38,7 @@ class GameBoard( var isGameOver = false var isHardDropInProgress = false // Make public var isPieceLocking = false // Make public + private var isPlayerSoftDrop = false // Track if the drop is player-initiated // Scoring state private var combo = 0 @@ -165,6 +166,10 @@ class GameBoard( return if (canMove(0, 1)) { currentPiece?.y = currentPiece?.y?.plus(1) ?: 0 + // Only add soft drop points if it's a player-initiated drop + if (isPlayerSoftDrop) { + score += 1 + } onPieceMove?.invoke() true } else { @@ -173,6 +178,15 @@ class GameBoard( } } + /** + * Player-initiated soft drop + */ + fun softDrop() { + isPlayerSoftDrop = true + moveDown() + isPlayerSoftDrop = false + } + /** * Hard drop the current piece */ @@ -182,12 +196,21 @@ class GameBoard( isHardDropInProgress = true val piece = currentPiece ?: return + // Count how many cells the piece will drop + var dropDistance = 0 + while (canMove(0, dropDistance + 1)) { + dropDistance++ + } + // Move piece down until it can't move anymore while (canMove(0, 1)) { piece.y++ onPieceMove?.invoke() } + // Add hard drop points (2 points per cell) + score += dropDistance * 2 + // Lock the piece immediately lockPiece() } @@ -604,4 +627,13 @@ class GameBoard( private fun getLastClearedLines(): List { return lastClearedLines.toList() } + + /** + * Update the game state (called by game loop) + */ + fun update() { + if (!isGameOver) { + moveDown() + } + } } \ No newline at end of file