Center title above high scores for both orientations

This commit is contained in:
cmclark00 2025-04-02 00:05:35 -04:00
parent f10c0260c9
commit 2d9de31a38

View file

@ -238,8 +238,14 @@ class TitleScreen @JvmOverloads constructor(
// Remove tetrominos that fell off the screen
tetrominos.removeAll(tetrominosToRemove)
// Draw title with "mint" in mint color
val titleY = height * 0.4f
// Position title based on orientation for optimal positioning
val titleY = if (resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
// In landscape mode, position in upper third of screen
height * 0.3f
} else {
// In portrait mode, center above high scores
height * 0.35f
}
// Measure each word without spaces
val pixelWidth = titlePaint.measureText("pixel")
@ -271,7 +277,14 @@ class TitleScreen @JvmOverloads constructor(
// Draw high scores using pre-allocated manager
val highScores: List<HighScore> = highScoreManager.getHighScores()
val highScoreY = height * 0.5f
// Adjust high scores position based on title position
val highScoreY = if (resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) {
height * 0.45f // In landscape, position high scores below title with more space
} else {
height * 0.5f // In portrait, keep in middle of screen
}
var lastHighScoreY = highScoreY
if (highScores.isNotEmpty()) {
// Calculate the starting X position to center the entire block of scores