# saon110/u_and_not_u architecture

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

- Interactive diagram: https://gitdiagram.com/saon110/u_and_not_u
- Repository: https://github.com/saon110/u_and_not_u

## Overview

##### Main Components
a. HTML & Styling Layer:
- index.html – Acts as the entry point and sets up the canvas where the game runs.
- style.css – Contains all the styling rules for the game’s UI elements.
b. Game Logic & Rendering (p5.js):
c. Game Entities (Classes):
- classes/player.js, enemy.js, greenball.js, redball.js – These files define the behavior and properties of various game entities (player, enemies, and other objects). They encapsulate functionality to support movements, collisions, and interactions.
d. Configuration/Development Support:
- jsconfig.json – Likely aids in code configuration or module resolution for the JavaScript environment, helping with autocompletion and proper integration of the project’s modules.

##### Out the Relationships and Interactions
a. index.html is the starting point that loads both style.css for visuals and libraries/sketch.js, initiating the p5.js game loop.
b. Within sketch.js, the game is initialized, and key objects (player, enemy, balls, etc.) are instantiated by calling constructors from the respective files in the classes directory.
d. p5.js functions interact with both the visual (canvas rendering) and logical (game state update) aspects, ensuring animations and interactions are smooth.

##### Incorporate Architectural Patterns and Design Principles
a. Separation of Concerns:
- UI/rendering is handled separately by the HTML/CSS layer.
- Game logic and state management reside in the p5.js based sketch.js and individual class files.
b. Modularization:
- Different game components and behaviors are modularized into separate JS class files.
c. Reusability and Extensibility:
- The distinct classes (player, enemy, greenball, redball) suggest that the project was designed to easily extend or modify behaviors for diverse game objects.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI & Styling Layer
    subgraph "UI & Styling"
        html["index.html"]:::ui
        css["style.css"]:::ui
    end

    %% Game Logic & Rendering (p5.js)
    subgraph "Game Logic & Rendering"
        sketch["p5.js Game Loop (sketch.js)"]:::logic
    end

    %% Game Entities
    subgraph "Game Entities"
        player["Player (player.js)"]:::entity
        enemy["Enemy (enemy.js)"]:::entity
        greenball["Greenball (greenball.js)"]:::entity
        redball["Redball (redball.js)"]:::entity
    end

    %% Configuration/Development Support
    config["Configuration (jsconfig.json)"]:::config

    %% Connections
    html -->|"loads"| sketch
    html -->|"includes"| css
    sketch -->|"instantiates"| player
    sketch -->|"instantiates"| enemy
    sketch -->|"instantiates"| greenball
    sketch -->|"instantiates"| redball
    config -->|"configures"| sketch

    %% Click Events
    click html "https://github.com/saon110/u_and_not_u/blob/master/index.html"
    click css "https://github.com/saon110/u_and_not_u/blob/master/style.css"
    click sketch "https://github.com/saon110/u_and_not_u/blob/master/libraries/sketch.js"
    click player "https://github.com/saon110/u_and_not_u/blob/master/classes/player.js"
    click enemy "https://github.com/saon110/u_and_not_u/blob/master/classes/enemy.js"
    click greenball "https://github.com/saon110/u_and_not_u/blob/master/classes/greenball.js"
    click redball "https://github.com/saon110/u_and_not_u/blob/master/classes/redball.js"
    click config "https://github.com/saon110/u_and_not_u/blob/master/jsconfig.json"

    %% Styles
    classDef ui fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef logic fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef entity fill:#ffdead,stroke:#333,stroke-width:2px;
    classDef config fill:#f08080,stroke:#333,stroke-width:2px;
```
