# agustinpaul0/supermariobros architecture

> Architecture diagram of the GitHub repository agustinpaul0/supermariobros, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agustinpaul0/supermariobros
- Repository: https://github.com/agustinpaul0/supermariobros

## Overview

Based on our analysis of the file tree and README, this project is a Java-based recreation of Super Mario Bros created for a university assignment. It features two game modes (Original and Alternative), a full suite of game elements (including enemies, power-ups, platforms, and characters), a persistent ranking system, and a complete game loop with menus and screens. The project also uses various design patterns (e.g., factories and visitors) to handle object creation and interactions.

##### Main Components
- Launcher & Entry Point: Represent the Launcher class (located in the “launcher” package) as the starting point of the application.
- Game Engine & Core Loop: Include the main game loop components found in the “juego” package (e.g., Juego, BucleJugador, BucleVentana, and MasterMind) that orchestrate the gameplay, entity updates, and level progressions.
- Game Entities & Elements: Illustrate a module that encapsulates the game’s elements:
- Characters (Mario in various states, SuperMario, etc. in the “elementos/personajes” package)
- Enemies (Goomba, Koopa, Lakitu, etc. in “elementos/enemigos”)
- Entities (including BolaDeFuego and general entities in “elementos/entidades”)
- Platforms and power-ups (in “elementos/plataformas” and “elementos/powerUps” pages)
- Factories: Show the factory classes (under “fabricas”) that are responsible for creating sprites, sounds, silhouettes, and other game elements in both “Original” and “Alternative” modes.
- Resource Management: Create nodes for the assets:
- Images (under “imagenes”), sounds (under “sonido”), and fonts (“fuentes”)
- User Interface & Windows: Include the UI/screen classes within “ventanas” (different screens for menus, game over, ranking, etc.).
- Observers and Visitors: Represent how the project uses the observer pattern (in “observers”) for graphical updates, and visitor classes (in “visitors”) to handle collision and interaction logic.
- Ranking & Persistence: Add a module for the ranking system (under “ranking”) which uses Java’s serialization for saving scores.
- Input Handling: Represent the keyboard sensor files (in “sensoresDeTeclas”) that monitor menu and game controls.

##### Establish Relationships & Data Flow
- How the Game Engine calls the Factories to instantiate and manage various Game Entities.
- UI modules to the Game Engine, illustrating how the game state is rendered and updated.
- Observers receiving updates from core game events and dispatching changes to the UI.
- Out the visitor pattern: entities (like enemies and platforms) accepted by visitor classes that handle collision detection and specific behavioral responses.
- That input handlers influence both menu navigation and in-game movement, linking the sensors with the Game Engine.

##### Architectural Patterns and Principles
- Factory Pattern: Note its role in decoupling object creation from game logic for sprites, sounds, and silhouettes – especially noting the mode-specific factories (Original vs. Alternative).
- Observer & Visitor Patterns: Clearly mark these as mechanisms to handle dynamic interactions such as collision detection and view update propagation.
- Separation of Concerns: Emphasize the modularity in separating game logic (game loop and entity management), UI (various “ventanas”), resource management (imagenes, sonido, fuentes), and persistence (ranking).

- Java (version implied by module usage and packages) is the central technology.
- The game’s graphics, windows, and input handling likely leverage standard Java GUI libraries (for example, Swing or AWT), though the exact framework isn’t specified; include a note on that if known.
- File assets and sound formats (wav files in the “sonido” package) should be annotated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User Interface & Windows"]:::ui
        Input["Input Handling"]:::input
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Launcher["Launcher"]:::core
        GameEngine["Game Engine & Core Loop"]:::core
        Factories["Entity Factories"]:::factory
        subgraph "Game Entities & Elements"
            Characters["Characters"]:::entity
            Enemies["Enemies"]:::entity
            GeneralEntities["General Entities"]:::entity
            Platforms["Platforms"]:::entity
            PowerUps["Power-Ups"]:::entity
        end
        Observers["Observers"]:::pattern
        Visitors["Visitors"]:::pattern
    end

    %% Data/Resource Layer
    subgraph "Data/Resource Layer"
        subgraph "Resource Management"
            Images["Images"]:::resource
            Sounds["Sounds"]:::resource
            Fonts["Fonts"]:::resource
        end
        LevelGen["Level Generation & Configuration"]:::level
        Ranking["Ranking & Persistence"]:::ranking
    end

    %% Connections
    Launcher -->|"starts"| GameEngine
    GameEngine -->|"calls"| Factories
    Factories -->|"creates"| Characters
    Factories -->|"creates"| Enemies
    Factories -->|"creates"| GeneralEntities
    Factories -->|"creates"| Platforms
    Factories -->|"creates"| PowerUps
    LevelGen -->|"configures"| GameEngine
    GameEngine -->|"renders"| UI
    GameEngine -->|"notifies"| Observers
    Observers -->|"updates"| UI
    Visitors -->|"applies-collision"| Characters
    Visitors -->|"applies-collision"| Enemies
    Visitors -->|"applies-collision"| Platforms
    Input -->|"controls"| GameEngine
    Input -->|"navigates"| UI
    Images -->|"assets"| Factories
    Sounds -->|"assets"| Factories
    Fonts -->|"assets"| Factories
    Ranking -->|"shows"| UI

    %% Click Events
    click Launcher "https://github.com/agustinpaul0/supermariobros/blob/main/CodigoFuente/src/launcher/Launcher.java"
    click GameEngine "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/juego"
    click Characters "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/elementos/personajes"
    click Enemies "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/elementos/enemigos"
    click GeneralEntities "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/elementos/entidades"
    click Platforms "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/elementos/plataformas"
    click PowerUps "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/elementos/powerUps"
    click Factories "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/fabricas"
    click Images "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/imagenes"
    click Sounds "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/sonido"
    click Fonts "https://github.com/agustinpaul0/supermariobros/blob/main/CodigoFuente/src/fuentes/Fuente.java"
    click LevelGen "https://github.com/agustinpaul0/supermariobros/blob/main/CodigoFuente/src/generadores/GeneradorDeNivel.java"
    click Ranking "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/ranking"
    click UI "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/ventanas"
    click Observers "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/observers"
    click Visitors "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/visitors"
    click Input "https://github.com/agustinpaul0/supermariobros/tree/main/CodigoFuente/src/sensoresDeTeclas"

    %% Styles
    classDef core fill:#b3d9ff,stroke:#000,stroke-width:2px;
    classDef entity fill:#ccffcc,stroke:#000,stroke-width:2px;
    classDef factory fill:#ffffcc,stroke:#000,stroke-width:2px;
    classDef resource fill:#e6ccff,stroke:#000,stroke-width:2px;
    classDef ui fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef input fill:#ffb3b3,stroke:#000,stroke-width:2px;
    classDef pattern fill:#d9d9d9,stroke:#000,stroke-width:2px;
    classDef level fill:#f2e6d9,stroke:#000,stroke-width:2px;
    classDef ranking fill:#cce6ff,stroke:#000,stroke-width:2px;
```
