# nubby29/2dplatformer architecture

> Architecture diagram of the GitHub repository nubby29/2dplatformer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nubby29/2dplatformer
- Repository: https://github.com/nubby29/2dplatformer

## Overview

This repository is a browser-based pixel platformer inspired by EPIC: The Musical. The evidenced playable workflow is: the player starts Troy, advances the opening dialogue, crosses the authored battlefield through platforming and combat encounters, reaches a checkpoint and the eastern gate, and sees completion. The main module coordinates the runtime; the engine, story controller, level data, and asset helpers provide distinct internal layers. The README documents broader saga progression, but the sampled level data implements only Troy. Some main-module details are omitted, so the graph avoids asserting uncertain call order.

Main entry points: [`src/main.js`](https://github.com/nubby29/2dplatformer/blob/main/src/main.js) (Game Runtime), [`src/assets.js`](https://github.com/nubby29/2dplatformer/blob/main/src/assets.js) (Sprite Helpers), [`index.html`](https://github.com/nubby29/2dplatformer/blob/main/index.html) (Browser Shell), [`src/story.js`](https://github.com/nubby29/2dplatformer/blob/main/src/story.js) (Opening Dialogue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Game Runtime"]
  node_runtime["Game Runtime<br/>[main.js]"]
end

subgraph group_content["Story and Progression"]
  node_dialogue["Opening Dialogue<br/>[story.js]"]
  node_level["Troy Level Data<br/>[levels.js]"]
  node_sagas["Saga Catalog<br/>[sagas.js]"]
  node_checkpoint["Checkpoint and Goal<br/>[main.js]"]
end

subgraph group_systems["Gameplay Systems"]
  node_simulation["Platform Simulation<br/>[engine.js]"]
  node_combat["Combat Encounters<br/>[main.js]"]
  node_hazards["Hazards and Debris<br/>[main.js]"]
  node_platforms["Moving Platforms<br/>[main.js]"]
  node_barriers["Breakable Barriers<br/>[main.js]"]
  node_ambushes["Triggered Ambushes<br/>[main.js]"]
end

subgraph group_visuals["Presentation"]
  node_rendering["Rendering and HUD<br/>[main.js]"]
  node_assethelpers["Sprite Helpers<br/>[assets.js]"]
  node_art["Pixel Art Assets"]
end

node_player(("Player"))
node_browser["Browser Shell<br/>[index.html]"]

node_player -->|"opens game"| node_browser
node_browser -->|"loads runtime"| node_runtime
node_player -->|"controls game"| node_runtime
node_runtime -->|"creates and advances"| node_dialogue
node_runtime -->|"reads Troy level"| node_level
node_runtime -->|"calls simulation"| node_simulation
node_runtime -->|"updates encounters"| node_combat
node_runtime -->|"updates hazards"| node_hazards
node_runtime -->|"updates platforms"| node_platforms
node_runtime -->|"updates barriers"| node_barriers
node_runtime -->|"triggers ambushes"| node_ambushes
node_runtime -->|"tracks progress"| node_checkpoint
node_runtime -->|"loads and draws sprites"| node_assethelpers
node_assethelpers -->|"loads image files"| node_art
node_runtime -->|"updates display"| node_rendering

click node_browser "https://github.com/nubby29/2dplatformer/blob/main/index.html"
click node_runtime "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_dialogue "https://github.com/nubby29/2dplatformer/blob/main/src/story.js"
click node_level "https://github.com/nubby29/2dplatformer/blob/main/src/levels.js"
click node_sagas "https://github.com/nubby29/2dplatformer/blob/main/data/sagas.js"
click node_simulation "https://github.com/nubby29/2dplatformer/blob/main/src/engine.js"
click node_combat "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_hazards "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_platforms "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_barriers "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_ambushes "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_checkpoint "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_rendering "https://github.com/nubby29/2dplatformer/blob/main/src/main.js"
click node_assethelpers "https://github.com/nubby29/2dplatformer/blob/main/src/assets.js"
click node_art "https://github.com/nubby29/2dplatformer/tree/main/assets"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runtime,node_browser toneBlue
class node_dialogue,node_level,node_sagas,node_checkpoint toneAmber
class node_simulation,node_combat,node_hazards,node_platforms,node_barriers,node_ambushes toneMint
class node_rendering,node_assethelpers,node_art toneRose
class node_player toneIndigo
```

## Components

### Game Runtime

- [Game Runtime](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`

### Story and Progression

- [Opening Dialogue](https://github.com/nubby29/2dplatformer/blob/main/src/story.js): `src/story.js`
- [Troy Level Data](https://github.com/nubby29/2dplatformer/blob/main/src/levels.js): `src/levels.js`
- [Saga Catalog](https://github.com/nubby29/2dplatformer/blob/main/data/sagas.js): `data/sagas.js`
- [Checkpoint and Goal](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`

### Gameplay Systems

- [Platform Simulation](https://github.com/nubby29/2dplatformer/blob/main/src/engine.js): `src/engine.js`
- [Combat Encounters](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`
- [Hazards and Debris](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`
- [Moving Platforms](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`
- [Breakable Barriers](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`
- [Triggered Ambushes](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`

### Presentation

- [Rendering and HUD](https://github.com/nubby29/2dplatformer/blob/main/src/main.js): `src/main.js`
- [Sprite Helpers](https://github.com/nubby29/2dplatformer/blob/main/src/assets.js): `src/assets.js`
- [Pixel Art Assets](https://github.com/nubby29/2dplatformer/tree/main/assets): `assets`

### Other components

- **Player**
- [Browser Shell](https://github.com/nubby29/2dplatformer/blob/main/index.html): `index.html`

## Connections

- Player → Browser Shell: opens game
- Browser Shell → Game Runtime: loads runtime
- Player → Game Runtime: controls game
- Game Runtime → Opening Dialogue: creates and advances
- Game Runtime → Troy Level Data: reads Troy level
- Game Runtime → Platform Simulation: calls simulation
- Game Runtime → Combat Encounters: updates encounters
- Game Runtime → Hazards and Debris: updates hazards
- Game Runtime → Moving Platforms: updates platforms
- Game Runtime → Breakable Barriers: updates barriers
- Game Runtime → Triggered Ambushes: triggers ambushes
- Game Runtime → Checkpoint and Goal: tracks progress
- Game Runtime → Sprite Helpers: loads and draws sprites
- Sprite Helpers → Pixel Art Assets: loads image files
- Game Runtime → Rendering and HUD: updates display
