# famisics/processing-game architecture

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

- Interactive diagram: https://gitdiagram.com/famisics/processing-game
- Repository: https://github.com/famisics/processing-game

## Overview

##### Main Components
- Game Client (Processing Application): This is the core game logic, including various scene files (scene1_Home.pde, scene2_Block.pde, …, scene7_Username.pde), input management, and other modules (e.g., Manager.pde, Network.pde). Additionally, there are unit files (unit_Ball.pde, unit_FPS.pde, unit_skill.pde) and virtual logic files (vLogic_Panel.pde, vLogic_Skill.pde, vLogic_block.pde) that handle specific gameplay mechanics.
- Assets and Configuration: Under the /game/src/ folder, you have configuration files (config.json, skills.csv), as well as assets like fonts, images, and sound files. This supports dynamic configuration (e.g., skill adjustments) and media resources used within the game.
- Launcher and Node-based Components: Two distinct Node.js server components exist:
- The node-launcher inside /game/src/node-launcher contains the source code for launcher.exe, which provides functionality to start the game and potentially handle some pre-launch configuration or network initiation.
- The node-proxy folder contains a standalone Node.js proxy server (with its own package.json and server.cjs) that mimics the functionality of launcher.exe and enables users on macOS or Linux to run the game by starting a proxy that manages network connections.
- Distribution Build: The /dist/ folder holds production executables (such as launcher.exe) which are built from the source.

##### Relationships and Interactions
- The Game Client is the central piece where the gameplay occurs. It loads configurations and assets at startup and executes various scenes and game logic.
- When multiplayer functionality is enabled (i.e., NET_isNetworkEnable set to true), the game client establishes a connection to the external public server via WebSocket (hosted with Render using node.js/express). In parallel, either launcher.exe (from /dist/) or the node-proxy server provides an interface to manage this connection.
- Assets and configurations are loaded by the game client from the game/src directory, ensuring that fonts, images, sounds, and game parameters (like skills) are dynamically available.

##### Architectural Patterns and Technologies
- Separation of Concerns: The project is split between the game logic (Processing code for scenes, units, and virtual logic) and the auxiliary Node.js servers (launcher and proxy) that handle networking.
- Client–Server Architecture: A clear division exists between the game client (which does rendering and game state management) and the server components (which manage multiplayer networking, using technologies such as WebSockets, Express, and Node.js).
- Resource Management: The use of directories for assets (fonts, images, sounds) reflects a modular approach for easy content management and scalability.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Game Client (Processing)"
        gc["game.pde"]:::processing
        subgraph "Scenes"
            s1["scene1_Home.pde"]:::processing
            s2["scene2_Block.pde"]:::processing
            s3["scene3_Channel.pde"]:::processing
            s4["scene4_Start.pde"]:::processing
            s5["scene5_Result.pde"]:::processing
            s6["scene6_Tutorial.pde"]:::processing
            s7["scene7_Username.pde"]:::processing
        end
        subgraph "Modules"
            m1["Manager.pde"]:::processing
            m2["Network.pde"]:::processing
            m3["Input.pde"]:::processing
        end
        subgraph "Units"
            u1["unit_Ball.pde"]:::processing
            u2["unit_FPS.pde"]:::processing
            u3["unit_skill.pde"]:::processing
        end
        subgraph "Virtual Logic"
            v1["vLogic_Panel.pde"]:::processing
            v2["vLogic_Skill.pde"]:::processing
            v3["vLogic_block.pde"]:::processing
        end
    end

    subgraph "Assets & Configuration"
        config["config.json"]:::assets
        skills["skills.csv"]:::assets
        fonts["Fonts Folder"]:::assets
        images["Images Folder"]:::assets
        sounds["Sounds Folder"]:::assets
    end

    subgraph "Launcher (Node.js)"
        nl_source["node-launcher Source"]:::launcher
        launcher_exe["launcher.exe"]:::launcher
    end

    subgraph "Node Proxy Server"
        np_source["node-proxy Source"]:::proxy
    end

    pms["Public Multiplayer Server\n(WebSocket,Express)"]:::external

    %% Data Flow Arrows
    gc -->|"loads"| config
    gc -->|"loads"| skills
    gc -->|"loads"| fonts
    gc -->|"loads"| images
    gc -->|"loads"| sounds

    m2 -->|"connects"| nl_source
    m2 -->|"connects"| np_source

    nl_source -->|"builds"| launcher_exe
    nl_source -->|"forwards"| pms
    np_source -->|"forwards"| pms

    %% Click Events for Game Client (Processing)
    click gc "https://github.com/famisics/processing-game/blob/main/game/game.pde"
    click s1 "https://github.com/famisics/processing-game/blob/main/game/scene1_Home.pde"
    click s2 "https://github.com/famisics/processing-game/blob/main/game/scene2_Block.pde"
    click s3 "https://github.com/famisics/processing-game/blob/main/game/scene3_Channel.pde"
    click s4 "https://github.com/famisics/processing-game/blob/main/game/scene4_Start.pde"
    click s5 "https://github.com/famisics/processing-game/blob/main/game/scene5_Result.pde"
    click s6 "https://github.com/famisics/processing-game/blob/main/game/scene6_Tutorial.pde"
    click s7 "https://github.com/famisics/processing-game/blob/main/game/scene7_Username.pde"
    click m1 "https://github.com/famisics/processing-game/blob/main/game/Manager.pde"
    click m2 "https://github.com/famisics/processing-game/blob/main/game/Network.pde"
    click m3 "https://github.com/famisics/processing-game/blob/main/game/Input.pde"
    click u1 "https://github.com/famisics/processing-game/blob/main/game/unit_Ball.pde"
    click u2 "https://github.com/famisics/processing-game/blob/main/game/unit_FPS.pde"
    click u3 "https://github.com/famisics/processing-game/blob/main/game/unit_skill.pde"
    click v1 "https://github.com/famisics/processing-game/blob/main/game/vLogic_Panel.pde"
    click v2 "https://github.com/famisics/processing-game/blob/main/game/vLogic_Skill.pde"
    click v3 "https://github.com/famisics/processing-game/blob/main/game/vLogic_block.pde"

    %% Click Events for Assets & Configuration
    click config "https://github.com/famisics/processing-game/blob/main/game/src/config.json"
    click skills "https://github.com/famisics/processing-game/blob/main/game/src/skills.csv"
    click fonts "https://github.com/famisics/processing-game/tree/main/game/src/fonts"
    click images "https://github.com/famisics/processing-game/tree/main/game/src/images"
    click sounds "https://github.com/famisics/processing-game/tree/main/game/src/sounds"

    %% Click Events for Launcher (Node.js)
    click nl_source "https://github.com/famisics/processing-game/tree/main/game/src/node-launcher"
    click launcher_exe "https://github.com/famisics/processing-game/blob/main/dist/launcher.exe"

    %% Click Event for Node Proxy Server
    click np_source "https://github.com/famisics/processing-game/tree/main/node-proxy"

    %% Styling
    classDef processing fill:#FFDDC1,stroke:#D45D79,stroke-width:2px;
    classDef assets fill:#E2F0CB,stroke:#82B74B,stroke-width:2px;
    classDef launcher fill:#C1E1FF,stroke:#407EC9,stroke-width:2px;
    classDef proxy fill:#FFF1B6,stroke:#D4A017,stroke-width:2px;
    classDef external fill:#E0E0E0,stroke:#707070,stroke-width:2px;
```
