mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 02:25: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
|
// Remove tetrominos that fell off the screen
|
||||||
tetrominos.removeAll(tetrominosToRemove)
|
tetrominos.removeAll(tetrominosToRemove)
|
||||||
|
|
||||||
// Draw title
|
// Draw title with "Mint" in mint color
|
||||||
val titleY = height * 0.4f
|
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
|
// Draw high scores using pre-allocated manager
|
||||||
val highScores: List<HighScore> = highScoreManager.getHighScores()
|
val highScores: List<HighScore> = highScoreManager.getHighScores()
|
||||||
|
@ -280,6 +297,8 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
val isLandscape = resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE
|
||||||
|
|
||||||
when (event.action) {
|
when (event.action) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
startX = event.x
|
startX = event.x
|
||||||
|
@ -289,18 +308,22 @@ class TitleScreen @JvmOverloads constructor(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
val deltaX = event.x - lastTouchX
|
// Skip tetromino movement in landscape mode
|
||||||
val deltaY = event.y - lastTouchY
|
if (!isLandscape) {
|
||||||
|
val deltaX = event.x - lastTouchX
|
||||||
// Update tetromino positions
|
val deltaY = event.y - lastTouchY
|
||||||
for (tetromino in tetrominos) {
|
|
||||||
tetromino.x += deltaX * 0.5f
|
// Update tetromino positions
|
||||||
tetromino.y += deltaY * 0.5f
|
for (tetromino in tetrominos) {
|
||||||
|
tetromino.x += deltaX * 0.5f
|
||||||
|
tetromino.y += deltaY * 0.5f
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTouchX = event.x
|
lastTouchX = event.x
|
||||||
lastTouchY = event.y
|
lastTouchY = event.y
|
||||||
invalidate()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue