# vhndaree/snooker architecture

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

- Interactive diagram: https://gitdiagram.com/vhndaree/snooker
- Repository: https://github.com/vhndaree/snooker

## Overview

##### Main Components Identification
The system can be broken down into these primary components:

a. Core Game Engine
- Game Manager (Game.js)
- Game World (GameWorld.js)
- Canvas Renderer (Canvas.js)

b. Game Components
- Ball System
- Player System
- Stick System

c. Input Handling System
- Mouse Handler
- Keyboard Handler
- Button State Manager

d. Asset Management
- Asset Loader
- Audio System
- Sprite System

**[Browser Environment]**

- [Core Game Engine]
- Game Manager
- Game World
- Canvas Renderer

- [Game Components]
- Ball System
- Player System
- Stick System

- [Input System]
- Mouse Handler
- Keyboard Handler
- Button State Manager

- [Asset Management]
- Asset Loader
- Audio System
- Sprite System

##### Technical Details

Annotations for:
- Canvas rendering context
- Collision detection system
- Vector mathematics system (Vector.js)
- Event handling system
- Asset preloading system

##### Implementation Notes

- The vanilla JavaScript implementation
- Browser compatibility considerations
- Resolution handling (1366 x 786 optimization)
- Real-time physics calculations
- Game rule implementation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Browser["Browser Environment"]
        subgraph Core["Core Game Engine"]
            GM["Game Manager"]:::core
            GW["Game World"]:::core
            CR["Canvas Renderer"]:::core
            GM <--> GW
            GW --> CR
        end

        subgraph Components["Game Components"]
            BS["Ball System"]:::component
            PS["Player System"]:::component
            SS["Stick System"]:::component
            BS <--> PS
            PS --> SS
        end

        subgraph Input["Input System"]
            MH["Mouse Handler"]:::input
            KH["Keyboard Handler"]:::input
            BSM["Button State Manager"]:::input
            MH --> BSM
            KH --> BSM
        end

        subgraph Assets["Asset Management"]
            AL["Asset Loader"]:::asset
            AS["Audio System"]:::asset
            SP["Sprite System"]:::asset
            AL --> AS
            AL --> SP
        end

        subgraph Support["Supporting Systems"]
            VM["Vector Mathematics"]:::support
            CD["Constants Definition"]:::support
            GV["Global Variables"]:::support
            UF["Utility Functions"]:::support
        end
    end

    %% Core interactions
    Input --> GM
    Assets --> Components
    Components <--> GW
    Support --> Core
    Support --> Components

    %% Style definitions
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef component fill:#90EE90,stroke:#333,stroke-width:2px
    classDef input fill:#FFB347,stroke:#333,stroke-width:2px
    classDef asset fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef support fill:#F0E68C,stroke:#333,stroke-width:2px

    %% Click events for component mapping
    click GM "https://github.com/Vhndaree/snooker/blob/master/js/Game.js"
    click GW "https://github.com/Vhndaree/snooker/blob/master/js/GameWorld.js"
    click CR "https://github.com/Vhndaree/snooker/blob/master/js/Canvas.js"
    click BS "https://github.com/Vhndaree/snooker/blob/master/js/game_components/Ball.js"
    click PS "https://github.com/Vhndaree/snooker/blob/master/js/game_components/Player.js"
    click SS "https://github.com/Vhndaree/snooker/blob/master/js/game_components/Stick.js"
    click MH "https://github.com/Vhndaree/snooker/blob/master/js/input_handler/MouseHandler.js"
    click KH "https://github.com/Vhndaree/snooker/blob/master/js/input_handler/KeyboardHandler.js"
    click BSM "https://github.com/Vhndaree/snooker/blob/master/js/input_handler/ButtonState.js"
    click AL "https://github.com/Vhndaree/snooker/blob/master/js/AssetsLoader.js"
    click AS "https://github.com/Vhndaree/snooker/tree/master/assets/audios"
    click SP "https://github.com/Vhndaree/snooker/tree/master/assets/sprites"
    click VM "https://github.com/Vhndaree/snooker/blob/master/js/Vector.js"
    click CD "https://github.com/Vhndaree/snooker/blob/master/js/Constants.js"
    click GV "https://github.com/Vhndaree/snooker/blob/master/js/Globals.js"
    click UF "https://github.com/Vhndaree/snooker/blob/master/js/Util.js"
```
