mirror of
https://github.com/cmclark00/mintris.git
synced 2025-05-18 10:25:19 +01:00
Add enhanced game over animation with falling blocks, screen shake, and dynamic text effects
This commit is contained in:
parent
7dccad8d12
commit
94e8d313c2
2 changed files with 268 additions and 37 deletions
|
@ -29,6 +29,8 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||
import android.graphics.Rect
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
|
@ -320,6 +322,7 @@ class MainActivity : AppCompatActivity() {
|
|||
* Show game over screen
|
||||
*/
|
||||
private fun showGameOver(score: Int) {
|
||||
Log.d("MainActivity", "Showing game over screen with score: $score")
|
||||
val gameTime = System.currentTimeMillis() - gameStartTime
|
||||
|
||||
// Update session stats
|
||||
|
@ -370,30 +373,36 @@ class MainActivity : AppCompatActivity() {
|
|||
if (isSoundEnabled) {
|
||||
gameMusic.playGameOver()
|
||||
}
|
||||
|
||||
// First trigger the animation in the game view
|
||||
Log.d("MainActivity", "Triggering game over animation")
|
||||
gameView.startGameOverAnimation()
|
||||
|
||||
// Show progression screen first with XP animation
|
||||
showProgressionScreen(xpGained, newRewards)
|
||||
|
||||
// Override the continue button behavior if high score needs to be shown
|
||||
val originalOnContinue = progressionScreen.onContinue
|
||||
|
||||
progressionScreen.onContinue = {
|
||||
// If this is a high score, show high score entry screen
|
||||
if (highScoreManager.isHighScore(score)) {
|
||||
showingHighScore = true
|
||||
showHighScoreEntry(score)
|
||||
} else {
|
||||
// Just show game over screen normally
|
||||
progressionScreen.visibility = View.GONE
|
||||
binding.gameOverContainer.visibility = View.VISIBLE
|
||||
|
||||
// Update theme selector if new themes were unlocked
|
||||
if (newRewards.any { it.contains("Theme") }) {
|
||||
updateThemeSelector()
|
||||
// Wait a moment before showing progression screen to let animation be visible
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
// Show progression screen first with XP animation
|
||||
showProgressionScreen(xpGained, newRewards)
|
||||
|
||||
// Override the continue button behavior if high score needs to be shown
|
||||
val originalOnContinue = progressionScreen.onContinue
|
||||
|
||||
progressionScreen.onContinue = {
|
||||
// If this is a high score, show high score entry screen
|
||||
if (highScoreManager.isHighScore(score)) {
|
||||
showingHighScore = true
|
||||
showHighScoreEntry(score)
|
||||
} else {
|
||||
// Just show game over screen normally
|
||||
progressionScreen.visibility = View.GONE
|
||||
binding.gameOverContainer.visibility = View.VISIBLE
|
||||
|
||||
// Update theme selector if new themes were unlocked
|
||||
if (newRewards.any { it.contains("Theme") }) {
|
||||
updateThemeSelector()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 2000) // Increased from 1000ms (1 second) to 2000ms (2 seconds)
|
||||
|
||||
// Vibrate to indicate game over
|
||||
vibrate(VibrationEffect.EFFECT_DOUBLE_CLICK)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue