Add enhanced game over animation with falling blocks, screen shake, and dynamic text effects

This commit is contained in:
cmclark00 2025-03-30 19:39:35 -04:00
parent 7dccad8d12
commit 94e8d313c2
2 changed files with 268 additions and 37 deletions

View file

@ -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)