mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-17 21:45:21 +01:00
Update title screen to show 'Mint' in mint color and disable controls in landscape mode
This commit is contained in:
parent
de46a20fc0
commit
212e52aea8
1 changed files with 33 additions and 10 deletions
|
@ -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<HighScore> = 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 -> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue