From 212e52aea80ece105637e3dffe95f6753aa18076 Mon Sep 17 00:00:00 2001 From: cmclark00 Date: Tue, 1 Apr 2025 23:46:15 -0400 Subject: [PATCH] Update title screen to show 'Mint' in mint color and disable controls in landscape mode --- .../com/pixelmintdrop/game/TitleScreen.kt | 43 ++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/pixelmintdrop/game/TitleScreen.kt b/app/src/main/java/com/pixelmintdrop/game/TitleScreen.kt index dee6d08..9056190 100644 --- a/app/src/main/java/com/pixelmintdrop/game/TitleScreen.kt +++ b/app/src/main/java/com/pixelmintdrop/game/TitleScreen.kt @@ -238,9 +238,26 @@ class TitleScreen @JvmOverloads constructor( // Remove tetrominos that fell off the screen tetrominos.removeAll(tetrominosToRemove) - // Draw title + // Draw title with "Mint" in mint color val titleY = height * 0.4f - canvas.drawText("Pixel Mint Drop", width / 2f, titleY, titlePaint) + val fullTitle = "Pixel Mint Drop" + val pixelWidth = titlePaint.measureText("Pixel ") + val mintWidth = titlePaint.measureText("Mint") + val dropWidth = titlePaint.measureText(" Drop") + + // Draw "Pixel" in theme color + canvas.drawText("Pixel ", width / 2f - (mintWidth + dropWidth) / 2, titleY, titlePaint) + + // Save the original color + val originalColor = titlePaint.color + + // Draw "Mint" in mint color (#3EB489) + titlePaint.color = Color.parseColor("#3EB489") + canvas.drawText("Mint", width / 2f - (dropWidth) / 2, titleY, titlePaint) + + // Restore the original color and draw "Drop" + titlePaint.color = originalColor + canvas.drawText(" Drop", width / 2f + (mintWidth) / 2, titleY, titlePaint) // Draw high scores using pre-allocated manager val highScores: List = highScoreManager.getHighScores() @@ -280,6 +297,8 @@ class TitleScreen @JvmOverloads constructor( } override fun onTouchEvent(event: MotionEvent): Boolean { + val isLandscape = resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE + when (event.action) { MotionEvent.ACTION_DOWN -> { startX = event.x @@ -289,18 +308,22 @@ class TitleScreen @JvmOverloads constructor( return true } MotionEvent.ACTION_MOVE -> { - val deltaX = event.x - lastTouchX - val deltaY = event.y - lastTouchY - - // Update tetromino positions - for (tetromino in tetrominos) { - tetromino.x += deltaX * 0.5f - tetromino.y += deltaY * 0.5f + // Skip tetromino movement in landscape mode + if (!isLandscape) { + val deltaX = event.x - lastTouchX + val deltaY = event.y - lastTouchY + + // Update tetromino positions + for (tetromino in tetrominos) { + tetromino.x += deltaX * 0.5f + tetromino.y += deltaY * 0.5f + } + + invalidate() } lastTouchX = event.x lastTouchY = event.y - invalidate() return true } MotionEvent.ACTION_UP -> {