5555
5656MIN_SCALE : int = 1
5757MAX_SCALE : int = 4
58- TALLY_TICK_INTERVAL_FRAMES : int = 4 # frames between each tally count-up tick
58+ TALLY_TICK_INTERVAL_FRAMES : int = 4 # frames between each ABM tally count-up tick
59+ TALLY_CITY_TICK_INTERVAL_FRAMES : int = 10 # frames between each city tally tick (slower)
60+ TALLY_PHASE_PAUSE_FRAMES : int = 24 # pause between the ABM tally and city tally
5961
6062
6163def _silo_key_map () -> dict [int , int ]:
@@ -164,6 +166,8 @@ class MissileCommandApp:
164166 tally_ticks_total : int = 0
165167 tally_ticks_done : int = 0
166168 tally_tick_frame_counter : int = 0
169+ _bonus_city_announced : bool = field (default = False , repr = False )
170+ _tally_phase_pause_remaining : int = field (default = 0 , repr = False )
167171
168172 # Wave-intro screen ("WAVE N" + alarm before attacks begin)
169173 _pending_wave_intro : bool = field (default = False , repr = False )
@@ -376,7 +380,7 @@ def _handle_events(self) -> None:
376380 elif event .key == pygame .K_F11 :
377381 self .renderer .toggle_fullscreen ()
378382 elif self ._awaiting_initials :
379- self ._handle_initials_keydown (event . key )
383+ self ._handle_initials_keydown (event )
380384 elif event .key == pygame .K_1 and self .game .state == GameState .ATTRACT :
381385 self ._start_game_from_attract ()
382386 else :
@@ -477,16 +481,53 @@ def _update(self) -> None:
477481 )
478482 self .tally_ticks_done = 0
479483 self .tally_tick_frame_counter = 0
484+ self ._tally_phase_pause_remaining = TALLY_PHASE_PAUSE_FRAMES
485+ self ._bonus_city_announced = False
480486 return
481487
482488 if self .game .state == GameState .WAVE_END :
483489 self .wave_end_timer -= 1
484490 if self .tally_ticks_done < self .tally_ticks_total :
485- self .tally_tick_frame_counter += 1
486- if self .tally_tick_frame_counter >= TALLY_TICK_INTERVAL_FRAMES :
487- self .tally_tick_frame_counter = 0
488- self .tally_ticks_done += 1
489- self .audio .play (SoundEvent .TALLY_TICK )
491+ # A brief pause between the ABM tally finishing and the
492+ # city tally starting, so the two feel like distinct
493+ # phases rather than one continuous count-up.
494+ at_phase_boundary = (
495+ self .tally_ticks_done == self .game .last_wave_remaining_abms
496+ and self .game .last_wave_remaining_abms > 0
497+ )
498+ if at_phase_boundary and self ._tally_phase_pause_remaining > 0 :
499+ self ._tally_phase_pause_remaining -= 1
500+ else :
501+ in_city_phase = (
502+ self .tally_ticks_done >= self .game .last_wave_remaining_abms
503+ )
504+ # Cities tick noticeably slower than ABMs -- there are
505+ # far fewer of them, so a fast count-up reads as a blur.
506+ tick_interval = (
507+ TALLY_CITY_TICK_INTERVAL_FRAMES
508+ if in_city_phase
509+ else TALLY_TICK_INTERVAL_FRAMES
510+ )
511+ self .tally_tick_frame_counter += 1
512+ if self .tally_tick_frame_counter >= tick_interval :
513+ self .tally_tick_frame_counter = 0
514+ # ABMs are tallied first, then surviving cities -- each
515+ # phase gets its own "roll up" sound (see data/sfx/README.md).
516+ tick_event = (
517+ SoundEvent .TALLY_TICK_CITY
518+ if in_city_phase
519+ else SoundEvent .TALLY_TICK_ABM
520+ )
521+ self .tally_ticks_done += 1
522+ self .audio .play (tick_event )
523+ elif (
524+ not self ._bonus_city_announced
525+ and self .game .last_wave_bonus_cities_awarded > 0
526+ ):
527+ # City points have finished tallying -- announce any bonus
528+ # city earned this wave.
529+ self ._bonus_city_announced = True
530+ self .audio .play (SoundEvent .BONUS_CITY )
490531 if self .wave_end_timer <= 0 :
491532 self .audio_cues .reset_for_new_wave ()
492533 self ._begin_wave_intro ()
@@ -516,7 +557,7 @@ def _update_initials_entry(self) -> None:
516557 self ._awaiting_initials = False
517558 self ._reset_to_attract ()
518559
519- def _handle_initials_keydown (self , key : int ) -> None :
560+ def _handle_initials_keydown (self , event : "pygame.event.Event" ) -> None :
520561 """Keyboard alternative to mouse-scrubbing on the initials
521562 screen. Left/Right look up the current letter's position in
522563 the charset and step it by one, writing straight to
@@ -526,8 +567,11 @@ def _handle_initials_keydown(self, key: int) -> None:
526567 trackball-recenter trick's per-frame motion event (posted even
527568 when the physical mouse hasn't moved), which is exactly why an
528569 earlier version of this appeared to "do nothing". Return/Space
529- confirms, mirroring a left mouse click.
570+ confirms, mirroring a left mouse click. Typing a letter/digit
571+ directly sets it and advances, for players who don't expect the
572+ arcade's trackball-style scrubbing.
530573 """
574+ key = event .key
531575 charset = self .INITIALS_CHARSET
532576 if key in (pygame .K_LEFT , pygame .K_RIGHT ) and self ._initials_slot < 3 :
533577 current = self ._initials [self ._initials_slot ]
@@ -539,6 +583,13 @@ def _handle_initials_keydown(self, key: int) -> None:
539583 self ._initials [self ._initials_slot ] = charset [idx ]
540584 elif key in (pygame .K_RETURN , pygame .K_KP_ENTER , pygame .K_SPACE ):
541585 self ._initials_slot += 1
586+ elif key == pygame .K_BACKSPACE and self ._initials_slot > 0 :
587+ self ._initials_slot -= 1
588+ elif self ._initials_slot < 3 :
589+ typed = getattr (event , "unicode" , "" ).upper ()
590+ if typed in charset :
591+ self ._initials [self ._initials_slot ] = typed
592+ self ._initials_slot += 1
542593
543594 @property
544595 def tally_displayed_score (self ) -> int :
@@ -570,7 +621,7 @@ def _render_initials_entry(
570621 """Draw the trackball-style initials entry screen."""
571622 self .renderer .native .fill ((0 , 0 , 0 ))
572623 self ._center_text ("ENTER YOUR INITIALS" , 8 , 50 )
573- self ._center_text ("MOVE MOUSE, CLICK TO SELECT " , 6 , 68 )
624+ self ._center_text ("USE MOUSE OR TYPE LETTERS " , 6 , 68 )
574625 self ._center_text (self .game .score_display .format_score (), 8 , 150 )
575626
576627 slot_w = 24
@@ -593,9 +644,12 @@ def _render(self) -> None:
593644 return
594645
595646 if self ._awaiting_initials :
596- fraction = self .crosshair_x / SCREEN_WIDTH
597- idx = max (0 , min (len (self .INITIALS_CHARSET ) - 1 , int (fraction * len (self .INITIALS_CHARSET ))))
598- self ._render_initials_entry (self ._initials , self ._initials_slot , self .INITIALS_CHARSET [idx ])
647+ active_char = (
648+ self ._initials [self ._initials_slot ]
649+ if self ._initials_slot < 3
650+ else ""
651+ )
652+ self ._render_initials_entry (self ._initials , self ._initials_slot , active_char )
599653 elif self ._pending_wave_intro :
600654 self ._render_wave_intro_screen ()
601655 elif self .game .state == GameState .ATTRACT :
@@ -650,15 +704,26 @@ def _render_high_score_table(self) -> None:
650704
651705 def _render_wave_end (self ) -> None :
652706 mult = self .game .multiplier
707+ # ABMs are tallied first (see _update), so city reveal only starts
708+ # once those ticks are done.
709+ cities_stamped = max (
710+ 0 , min (
711+ self .tally_ticks_done - self .game .last_wave_remaining_abms ,
712+ self .game .last_wave_surviving_cities ,
713+ ),
714+ )
653715 self ._center_text (f"WAVE { self .game .wave_number - 1 } COMPLETE" , 8 , 50 )
654716 self ._center_text (
655717 f"CITIES { self .game .last_wave_surviving_cities } X 100 X { mult } " , 7 , 90 ,
656718 )
719+ self .renderer .draw_city_tally_row (self .game .last_wave_surviving_cities , cities_stamped )
657720 self ._center_text (
658- f"ABMS { self .game .last_wave_remaining_abms } X 5 X { mult } " , 7 , 105 ,
721+ f"ABMS { self .game .last_wave_remaining_abms } X 5 X { mult } " , 7 , 118 ,
659722 )
660- self ._center_text (f"BONUS { self .game .last_wave_bonus } " , 8 , 125 )
661- self ._center_text (f"SCORE { self .tally_displayed_score } " , 8 , 150 )
723+ self ._center_text (f"BONUS { self .game .last_wave_bonus } " , 8 , 138 )
724+ self ._center_text (f"SCORE { self .tally_displayed_score } " , 8 , 163 )
725+ if self ._bonus_city_announced :
726+ self ._center_text ("BONUS CITY" , 8 , 183 , color = (255 , 220 , 0 ))
662727
663728 def _render_game_over (self ) -> None :
664729 self .renderer .draw_the_end (self .game_over_timer )
0 commit comments