Skip to content

Improve Game Over Screen & Restart Logic - #65

Open
Saniya-2022 wants to merge 2 commits into
dishu4u:mainfrom
Saniya-2022:feature/improve-game-over-screen
Open

Improve Game Over Screen & Restart Logic#65
Saniya-2022 wants to merge 2 commits into
dishu4u:mainfrom
Saniya-2022:feature/improve-game-over-screen

Conversation

@Saniya-2022

Copy link
Copy Markdown

🎮 Improve Game Over Screen & Add Proper Restart Functionality

Description

This PR enhances the game over experience and fixes restart functionality, providing a professional UI and better user experience.

Issues Fixed

Changes Made

1. ✨ Enhanced Game Over Screen

  • Added professional styled game over screen with dark overlay (alpha 220)
  • Displays "GAME OVER!" title with red shadow effect for better visibility
  • Shows final score prominently in white text
  • Includes Pac-Man and ghost sprites for visual appeal
  • Added always-visible yellow "Press ANY KEY to Restart!" message
  • Improved overall UI/UX with better typography and layout

2. 🔧 Fixed Game Loop Behavior

  • Game loop now stops immediately when game ends (prevents game state updates)
  • Eliminates screen flickering that occurred in previous implementation
  • Game over screen stays visible until user presses a key
  • Added 500ms delay to ensure screen renders properly

3. 🎯 Improved Restart Logic

  • Created dedicated restartGame() method for clean code organization
  • Properly resets all game state:
    • Loads fresh map
    • Resets Pac-Man and ghost positions to starting positions
    • Resets lives to 3
    • Resets score to 0
    • Clears gameOver flag
  • Safely checks if game loop is already running before restart
  • Prevents edge cases with multiple restart attempts

4. 📋 Code Quality Improvements

  • Removed blinking effect from restart message (message now always visible)
  • Reorganized keyReleased() method for better readability
  • Added proper return statements to prevent accidental command execution
  • Improved code comments for clarity
  • Followed Java coding standards throughout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Game Over Screen Add Game Restart Option

2 participants