Game Screens

Each major game state is managed by a dedicated screen module located in the /screens directory. All screen classes follow a consistent interface, containing handle_events, update, and render methods, which are called by the main game loop in main.py.

screens.menu.MenuScreen

This is the first screen the player sees. It's responsible for: - Displaying the game title and subtitle. - Creating and managing the main navigation buttons (Play, Options, Exit) using the MenuButtonSet from utils.buttons. - Handling user input to navigate to other game states (like selection) or to quit the game.

# From screens/menu.py
class MenuScreen:
    def __init__(self, game_instance):
        self.game = game_instance
        self.button_set = MenuButtonSet(...)
        self._setup_buttons()

    def handle_events(self, events):
        clicked_button = self.button_set.handle_events(events)
        if clicked_button == "JOGAR":
            return "selection"  # Request state change
        return None

    def render(self, screen):
        screen.fill(BLACK)
        # ... render title ...
        self.button_set.draw(screen)

screens.selection.SelectionScreen

The hero selection screen is a more complex module that showcases the integration with the AI asset pipeline. Its responsibilities include:

  • Loading Hero Data: Reads hero information from the HEROES dictionary in config.py.
  • Preloading AI Assets: Interacts with the AssetGenerator to generate and load hero-specific backgrounds and sprites.
  • Dynamic Backgrounds: Switches the background image dynamically based on the currently selected hero.
  • Hero Display: Renders the selected hero's sprite, name, stats, and description.
  • Navigation: Allows the player to cycle through heroes using arrow keys or on-screen buttons.
  • State Transition: Upon confirmation, it sets the selected_hero in the main game instance and signals a transition to the gameplay state.
# From screens/selection.py
class SelectionScreen:
    def __init__(self, game_instance):
        self.asset_generator = AssetGenerator(...)
        self._preload_assets() # Generates and loads backgrounds/sprites

    def _select_hero(self, hero_type):
        self.selected_hero = hero_type
        self._load_background(hero_type) # Dynamically changes the background

    def handle_events(self, events):
        # ... event handling for navigation and confirmation ...
        if self.confirm_button.handle_event(event):
            self.game.selected_hero = self.selected_hero
            return "gameplay"
        return None

Future Screens (Unimplemented)

As per the development roadmap, the following screens are planned but not yet implemented. They exist as placeholder files in the repository:

  • screens/gameplay.py: Will manage the core combat loop, including card drawing, turn management, and rendering the battlefield.
  • screens/events.py: Will handle the random event encounters that occur between combat.
  • screens/gameover.py: Will display the end-of-run summary and provide options to restart or return to the menu.