Skip to content

Fix audio driver fallback, NameError in InputBox, and add high score entry prompt#13

Merged
CAG07 merged 3 commits intomainfrom
copilot/fix-audio-driver-issues
Feb 15, 2026
Merged

Fix audio driver fallback, NameError in InputBox, and add high score entry prompt#13
CAG07 merged 3 commits intomainfrom
copilot/fix-audio-driver-issues

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 15, 2026

Three bugs: audio fails after adding SDL driver fallback logic, NameError: name 'screen' is not defined crashes the game at game over when pressing Escape in the InputBox, and high score entry is never prompted regardless of score.

Audio driver env var restoration (src/ui/audio.py, missile-defense.py)

  • SDL_AUDIODRIVER was restored to the original (possibly broken) value even after a working fallback driver was found — now only restores on failure
  • missile-defense.py upgraded from bare try/except to the same multi-driver fallback loop (Nonepulseaudioalsadspdummy)

NameError in text.py

  • exit_game(screen) referenced an undefined screen variable in module scope → replaced with pygame.display.get_surface()
  • Removed pygame.display.update() from InputBox.draw() — caller now controls display updates, eliminating the stale white rectangle outline

High score entry flow (missile-defense.py, main.py)

  • InputBox now only appears when check_high_score() confirms the player qualifies
  • Entered initials are saved via update_high_scores() + save_high_scores() instead of hardcoded "---"
  • main.py gains _prompt_initials() — a minimal input loop accepting up to 3 alphanumeric characters
# Before: always saved with placeholder name
self.high_scores = update_high_scores(score, "---", self.high_scores)

# After: only saves when qualified, prompts for name
score_pos = check_high_score(score, self.high_scores)
if score_pos > 0:
    name = self._prompt_initials()
    self.high_scores = update_high_scores(score, name, self.high_scores)
    save_high_scores(self.scores_file, self.high_scores)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 15, 2026 20:15
…screen in text.py InputBox

Co-authored-by: CAG07 <18625460+CAG07@users.noreply.github.com>
…ls input

Co-authored-by: CAG07 <18625460+CAG07@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix audio not working after adding conditionals Fix audio driver fallback, NameError in InputBox, and add high score entry prompt Feb 15, 2026
Copilot AI requested a review from CAG07 February 15, 2026 20:17
@CAG07 CAG07 marked this pull request as ready for review February 15, 2026 20:20
@CAG07 CAG07 merged commit 0d818e2 into main Feb 15, 2026
4 checks passed
@CAG07 CAG07 deleted the copilot/fix-audio-driver-issues branch February 15, 2026 20:20
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.

2 participants