# marwahns/game-avoid-the-shuriken architecture

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

- Interactive diagram: https://gitdiagram.com/marwahns/game-avoid-the-shuriken
- Repository: https://github.com/marwahns/game-avoid-the-shuriken

## Overview

##### Project Type and Purpose
- Type: Single-player arcade game implemented in two runtimes:
a) Processing (Java-based .pde files)
b) p5.js (JavaScript browser version)
- Purpose: Provide a playable game (“Avoid The Shuriken”) plus a small static website for docs, download links, and marketing.

##### File Structure
- Top‐level directories:
- asset/ (fonts, images, sounds used by both game runtimes)
- page/p5/ (browser-based game using p5.js, with Game.js, Menu.js, Ninja.js, Shuriken.js)
- page/web/ (static website pages: index.html, about_us.html, try_game.html, CSS, JS, images)
- processing/ (.pde sketches and properties for the Processing IDE)
- Notable files:
- p5.js library (page/p5/addons/p5.js)
- HTML entry points (page/p5/project/index.html, page/web/index.html, try_game.html)
- Asset types: audio (.mp3), fonts (.vlw), images (various subfolders)

##### README
- Confirms it’s a Processing game (“Game with processing”), no extra architecture notes.

##### Main Components & Their Relationships
A. Client Layers
1. Browser (serves static site & p5.js game)
2. Processing IDE / Java Runtime (runs desktop .pde sketches)
B. Static Marketing Website
- HTML/CSS/JS pages under page/web/
- “Try Game” link → page/p5/project/index.html
C. Game Engine Layer
- p5.js library (animation loop, drawing API)
- Processing core (Java-based sketch runner)
D. Game Modules (shared conceptual layer)
- Menu component
- Game logic component
- Ninja entity
- Shuriken entity
E. Asset Store
- Fonts, images, sounds loaded at runtime by both p5.js and Processing
F. Build/Run Scripts (minimal—just the IDE or static file server)

- Browser → fetch static site → load try_game.html → load p5.js → load Game.js modules → request assets → render game to Canvas → user input flow back to Game modules
- Processing IDE → open game.pde → import Menu.pde, Ninja.pde, Shuriken.pde → load assets from asset/ → render to Processing window → user input

##### Architectural Patterns & Principles
- Separation of Concerns: UI (HTML/CSS/JS) vs. Game Logic (JS/Processing) vs. Assets
- Modular JS: each game class in its own file (Game.js, Menu.js, etc.)
- Polyglot delivery: same assets support two runtimes

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Static Marketing Website
    subgraph "Static Marketing Website"
        SW_Index["index.html"]:::doc
        SW_About["about_us.html"]:::doc
        SW_Try["try_game.html"]:::doc
        SW_Doc["documentation.html"]:::doc
        SW_Download["download.html"]:::doc
        SW_Related["related_link.html"]:::doc
        CSS["main.css"]:::web
        JS["main.js"]:::web
    end

    %% Browser-Game (p5.js)
    subgraph "Browser-Game (p5.js)"
        Browser["Browser"]:::runtime
        PGEntry["project/index.html"]:::doc
        P5Lib["p5.js"]:::jsLogic
        subgraph "Game Modules"
            GJS["Game.js"]:::jsLogic
            MJS["Menu.js"]:::jsLogic
            NJS["Ninja.js"]:::jsLogic
            SJS["Shuriken.js"]:::jsLogic
        end
        Canvas["Canvas"]:::runtime
    end

    %% Processing-Game (Desktop Sketch)
    subgraph "Processing-Game (Desktop Sketch)"
        IDE["Processing IDE"]:::runtime
        Sketch["game.pde"]:::jsLogic
        SKProp["sketch.properties"]:::jsLogic
        subgraph "Processing Modules"
            MPDE["Menu.pde"]:::jsLogic
            NPDE["Ninja.pde"]:::jsLogic
            SPDE["Shuriken.pde"]:::jsLogic
        end
        PWindow["Processing Window"]:::runtime
    end

    %% Asset Store
    subgraph "Asset Store"
        AssetStore["Asset Store"]:::assets
        Fonts["Fonts"]:::assets
        Images["Images"]:::assets
        Sounds["Sounds"]:::assets
    end

    %% Connections - Static Site to Browser
    SW_Try -->|"Try Game link"| Browser
    SW_Index -->|"HTTP GET"| SW_Index
    SW_About --> SW_About
    SW_Doc --> SW_Doc
    SW_Download --> SW_Download
    SW_Related --> SW_Related
    SW_Index --> SW_Try
    SW_Try --> CSS
    SW_Try --> JS

    %% Browser-Game Flows
    Browser -->|"HTTP GET"| PGEntry
    PGEntry -->|"load p5.js"| P5Lib
    P5Lib -->|"import modules"| GJS
    P5Lib -->|"import modules"| MJS
    P5Lib -->|"import modules"| NJS
    P5Lib -->|"import modules"| SJS
    GJS -->|"load asset"| Fonts
    GJS -->|"load asset"| Images
    GJS -->|"load asset"| Sounds
    MJS -->|"load asset"| Fonts
    NJS -->|"load asset"| Images
    SJS -->|"load asset"| Sounds
    GJS -->|"render frame"| Canvas
    Canvas -->|"user input"| GJS

    %% Processing-Game Flows
    IDE -->|"open sketch"| Sketch
    Sketch -->|"include properties"| SKProp
    Sketch -->|"import modules"| MPDE
    Sketch -->|"import modules"| NPDE
    Sketch -->|"import modules"| SPDE
    MPDE -->|"load asset"| Fonts
    NPDE -->|"load asset"| Images
    SPDE -->|"load asset"| Sounds
    Sketch -->|"render frame"| PWindow
    PWindow -->|"user input"| Sketch

    %% Asset Store links
    AssetStore --> Fonts
    AssetStore --> Images
    AssetStore --> Sounds

    %% Click Events
    click AssetStore "https://github.com/marwahns/game-avoid-the-shuriken/tree/main/asset/"
    click Fonts "https://github.com/marwahns/game-avoid-the-shuriken/tree/main/asset/font/"
    click Images "https://github.com/marwahns/game-avoid-the-shuriken/tree/main/asset/images/"
    click Sounds "https://github.com/marwahns/game-avoid-the-shuriken/tree/main/asset/sound/"
    click SW_Index "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/index.html"
    click SW_About "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/about_us.html"
    click SW_Try "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/try_game.html"
    click SW_Doc "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/documentation.html"
    click SW_Download "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/download.html"
    click SW_Related "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/related_link.html"
    click CSS "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/assets/css/main.css"
    click JS "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/web/assets/js/main.js"
    click P5Lib "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/p5/addons/p5.js"
    click PGEntry "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/p5/project/index.html"
    click GJS "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/p5/project/Game.js"
    click MJS "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/p5/project/Menu.js"
    click NJS "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/p5/project/Ninja.js"
    click SJS "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/page/p5/project/Shuriken.js"
    click Sketch "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/processing/game.pde"
    click SKProp "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/processing/sketch.properties"
    click MPDE "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/processing/Menu.pde"
    click NPDE "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/processing/Ninja.pde"
    click SPDE "https://github.com/marwahns/game-avoid-the-shuriken/blob/main/processing/Shuriken.pde"

    %% Styles
    classDef web fill:#add8e6,stroke:#333,stroke-width:1px
    classDef jsLogic fill:#90ee90,stroke:#333,stroke-width:1px
    classDef assets fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef runtime fill:#f4c2c2,stroke:#333,stroke-width:1px
    classDef doc fill:#fdfd96,stroke:#333,stroke-width:1px
```
