# oralbekurusbekov/fireboy_and_watergirl architecture

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

- Interactive diagram: https://gitdiagram.com/oralbekurusbekov/fireboy_and_watergirl
- Repository: https://github.com/oralbekurusbekov/fireboy_and_watergirl

## Overview

##### Project Type and Purpose
- This is a small Java-based desktop puzzle game (“Fireboy_and_Watergirl”).
- It uses a Swing/AWT window (GameFrame) and a custom game panel with a real-time game loop, loads level data from text files, and models game entities (players, doors, walls, pools).

##### File/Directory Analysis
- src/
- Main.java – application entry point.
- GameFrame.java – the top-level window.
- GamePanel.java – the canvas: game loop, rendering, input.
- Instruction.java – draws on-screen instructions.
- Player.java, Door.java, Wall.java, Pool.java – core game objects.
- LevelFiles/LevelX.txt – level definitions parsed at runtime.
- README.md – only project title (no extra architecture info).

##### High-Level Components
a. Entry Point & Launcher
- Main class
b. Presentation / UI Layer
- GameFrame (JFrame)
- GamePanel (JPanel)
- Instruction renderer
c. Core Game Loop & Logic
- Game loop (tick/update/render) inside GamePanel
- Input handler (keyboard events → Player)
- Collision & rule engine (interactions among Player, Wall, Pool, Door)
d. Domain Entities
- Player (position, state)
- Wall (obstacle)
- Pool (hazard)
- Door (goal)
e. Data / Level Loader
- LevelLoader (reads LevelFiles/*.txt)
- LevelFiles directory (external resource)

##### Relationships & Data Flow
- Main → initializes → GameFrame
- GameFrame → embeds → GamePanel
- GamePanel on start → reads level via LevelLoader → instantiates domain Entities
- GamePanel’s game loop:
- READ keyboard events → passes to InputHandler → updates Player state
- UPDATE each Entity (position, collisions)
- RENDER Entities and Instruction overlays
- Collision outcomes → door reached → load next level from LevelFiles

##### Architectural Patterns & Design Principles
- Layered design: Presentation (UI) → Core Logic → Data (level files)
- Game Loop pattern: single-threaded tick/update/render
- Entity/component separation: each game object has its own class
- Resource isolation: level data externalized in text files

##### Technologies & Frameworks
- Java SE (Swing/AWT) for UI
- Plain text for level definitions
- No external network services or databases

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        Main["Main"]:::ui
        GameFrame["GameFrame"]:::ui
        GamePanel["GamePanel"]:::ui
        Instruction["Instruction"]:::ui
    end

    subgraph "Core Logic"
        InputHandler["InputHandler"]:::core
        GameLoop["Game Loop"]:::core
        CollisionEngine["Collision & Rule Engine"]:::core
    end

    subgraph "Domain Entities"
        Player["Player"]:::entity
        Wall["Wall"]:::entity
        Pool["Pool"]:::entity
        Door["Door"]:::entity
    end

    subgraph "Data Layer"
        LevelLoader["LevelLoader"]:::data
        LevelFiles["LevelFiles"]:::data
    end

    Main -->|"init()"| GameFrame
    GameFrame -->|"embed()"| GamePanel
    GamePanel -->|"startLoop()"| GameLoop
    GamePanel -->|"loadLevels()"| LevelLoader
    LevelLoader -->|"reads levels"| LevelFiles

    GameLoop -->|"readKeyboard"| InputHandler
    InputHandler -->|"updatePlayer"| Player

    GameLoop -->|"updateEntities"| CollisionEngine
    CollisionEngine -->|"resolveCollisions"| Player
    CollisionEngine -->|"resolveCollisions"| Wall
    CollisionEngine -->|"resolveCollisions"| Pool
    CollisionEngine -->|"resolveCollisions"| Door

    GameLoop -->|"renderEntities"| GamePanel
    GameLoop -->|"renderInstruction"| Instruction

    Door -->|"reach"| LevelLoader

    click Main "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/Main.java"
    click GameFrame "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/GameFrame.java"
    click GamePanel "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/GamePanel.java"
    click Instruction "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/Instruction.java"
    click Player "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/Player.java"
    click Wall "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/Wall.java"
    click Pool "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/Pool.java"
    click Door "https://github.com/oralbekurusbekov/fireboy_and_watergirl/blob/main/src/Door.java"
    click LevelFiles "https://github.com/oralbekurusbekov/fireboy_and_watergirl/tree/main/src/LevelFiles"

    classDef ui fill:#ADD8E6,stroke:#000;
    classDef core fill:#90EE90,stroke:#000;
    classDef data fill:#FFD700,stroke:#000;
    classDef entity fill:#FFFACD,stroke:#000;
```
