mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 09:45:20 +01:00
Add scoring for soft and hard drops, remove automatic falling points
This commit is contained in:
parent
9ab9b53407
commit
7614cef7e5
2 changed files with 35 additions and 3 deletions
|
@ -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()
|
||||
|
|
|
@ -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<Int> {
|
||||
return lastClearedLines.toList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the game state (called by game loop)
|
||||
*/
|
||||
fun update() {
|
||||
if (!isGameOver) {
|
||||
moveDown()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue