# yell0wsuit/cuttherope-h5dx architecture

> Architecture diagram of the GitHub repository yell0wsuit/cuttherope-h5dx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yell0wsuit/cuttherope-h5dx
- Repository: https://github.com/yell0wsuit/cuttherope-h5dx

## Overview

#### Purpose and runtime
Cut the Rope: H5DX is a deprecated, fan-maintained HTML5/TypeScript implementation and enhancement of Cut the Rope. It is a Vite-built browser game: `index.html` hosts the client entry, while `src/app.ts` and `src/ctr.ts` initialize application/game behavior. Static deployment is configured for Netlify in `netlify.toml`; the published game can also be served as static assets.

#### Application composition
The runtime is organized around custom canvas-oriented engine abstractions rather than a third-party game engine. Rendering primitives, scene graph-like elements, animation timelines, camera, particles, and texture display live in `src/visual/GameObject.ts`, `src/visual/Camera2D.ts`, and `src/visual/Timeline.ts`. Reusable geometry, views/controllers, storage, and texture wrappers form the lower-level boundary in `src/core/RootControllerBase.ts`, `src/core/View.ts`, and `src/core/SettingStorage.ts`.

#### Game orchestration and state
`src/game/CTRRootController.ts` is the game-level root controller, with `src/game/GameController.ts` coordinating play behavior and `src/game/LevelState.ts` representing level progress/state. `src/GameScene.ts` and `src/gameScene/init.ts` assemble a playable scene; initialization is decomposed into background, candy, animation, UI-star, and reset stages under `src/gameScene/initGameScene/`. This separates level setup/restart concerns from frame-by-frame gameplay.

#### Data-driven level loading
Level definitions are static JSON assets under `public/data/boxes/levels/` (for example `public/data/boxes/levels/00-01.json` and `public/data/boxes/levels/10-50.json`). Scene loaders translate this authored data into runtime entities: `src/gameScene/loaders.ts`, `src/gameScene/loadObjects/loadGameDesign.ts`, and specialized loaders such as `src/gameScene/loadObjects/loadCandy.ts`. Box/edition configuration and menu text are externalized in `public/data/config/editions/net-box-text.json` and `public/data/resources/menu-strings.json`.

#### Simulation and interaction pipeline
The frame update enters through `src/gameScene/update.ts` and dispatches behavior across focused systems: physics, interactions, collectibles, hazards, targets, camera, and special mechanics under `src/gameScene/systems/`. The physical model is custom constraint-based simulation, centered on `src/physics/MaterialPoint.ts`, `src/physics/ConstraintSystem.ts`, and `src/physics/Gravity.ts`. Gameplay objects—ropes, candy, bubbles, pumps, spikes, ghosts, etc.—are concrete implementations in `src/game/`, while update modules handle collisions, cuts, rope management, teleportation, and lifecycle transitions in `src/gameScene/sceneUpdate/`.

#### Resources, resolution, and presentation
A resource manager/loading pipeline fetches and scales images, JSON, and audio through `src/resources/ResourceMgr.ts`, `src/resources/PreLoader.ts`, and `src/resources/TextureAtlasParser.ts`. Assets are served directly from `public/`, including atlas metadata in `public/images/1920/game/`, sound in `public/audio/`, and video in `public/video/`. Resolution-specific configuration (`src/config/resolutions/1920x1080.ts`, `src/config/resolutions/scale.ts`) and `src/ZoomManager.ts` adapt the canvas/UI across target sizes.

#### UI, persistence, and external boundaries
The menu/panel layer manages navigation, results, skins, audio options, and game flow through `src/ui/InterfaceManager/index.ts`, `src/ui/PanelManager.ts`, and `src/ui/ScoreManager.ts`. Browser boundaries include DOM/canvas input utilities, local settings storage, Web Audio asset playback, and optional analytics (`src/utils/PointerCapture.ts`, `src/core/SettingStorage.ts`, `src/analytics.js`). No application backend or persistent remote service is evident; levels and media are bundled/static-loaded client assets.

Main entry points: [`src/GameScene.ts`](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/GameScene.ts) (Game scene), [`src/game/CTRRootController.ts`](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/game/CTRRootController.ts) (Game root controller), [`src/ui/InterfaceManager/index.ts`](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/ui/InterfaceManager/index.ts) (Interface manager), [`src/resources/ResourceMgr.ts`](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/resources/ResourceMgr.ts) (Resource pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Browser bootstrap"]
  node_html["Client entry<br/>HTML entry<br/>[index.html]"]
  node_app["App bootstrap<br/>TypeScript bootstrap<br/>[app.ts]"]
  node_ctr["Game startup<br/>startup module<br/>[ctr.ts]"]
end

subgraph group_engine["Engine and resources"]
  node_visual["Canvas visual runtime<br/>rendering and animation<br/>[GameObject.ts]"]
  node_resources["Resource pipeline<br/>asset loader<br/>[ResourceMgr.ts]"]
end

subgraph group_gameplay["Game scene and simulation"]
  node_root["Game root controller"]
  node_controller["Game controller<br/>play coordinator<br/>[GameController.ts]"]
  node_scene["Game scene<br/>scene assembly<br/>[GameScene.ts]"]
  node_sceneinit["Scene initialization<br/>level setup stages<br/>[init.ts]"]
  node_loaders["Scene loaders<br/>authored-data loaders<br/>[loaders.ts]"]
  node_update["Frame update<br/>simulation dispatcher<br/>[update.ts]"]
  node_mechanics["Scene mechanics<br/>interaction systems"]
  node_physics["Constraint physics<br/>custom simulation"]
end

subgraph group_presentation["UI and adaptation"]
  node_ui["Interface manager<br/>menu and panel flow<br/>[index.ts]"]
  node_viewport["Viewport adaptation<br/>canvas scaling<br/>[ZoomManager.ts]"]
  node_storage["Settings storage<br/>browser persistence<br/>[SettingStorage.ts]"]
end

subgraph group_assets["Static content"]
  node_levels[("Level definitions<br/>level JSON")]
  node_media[("Media assets<br/>public assets")]
end

node_html -->|"loads"| node_app
node_app -->|"starts"| node_ctr
node_ctr -->|"creates"| node_root
node_root -->|"coordinates"| node_controller
node_controller -->|"runs"| node_scene
node_scene -->|"assembles"| node_sceneinit
node_sceneinit -->|"loads level objects"| node_loaders
node_levels -->|"authored input"| node_loaders
node_scene -->|"updates each frame"| node_update
node_update -->|"dispatches"| node_mechanics
node_mechanics -->|"simulates constraints"| node_physics
node_scene -->|"renders through"| node_visual
node_resources -->|"fetches"| node_media
node_resources -->|"provides textures"| node_visual
node_root -->|"drives game flow"| node_ui
node_ui -->|"persists settings"| node_storage
node_scene -->|"adapts canvas"| node_viewport
node_ui -->|"scales UI"| node_viewport

click node_html "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/index.html"
click node_app "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/app.ts"
click node_ctr "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/ctr.ts"
click node_root "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/game/CTRRootController.ts"
click node_controller "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/game/GameController.ts"
click node_scene "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/GameScene.ts"
click node_sceneinit "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/gameScene/init.ts"
click node_loaders "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/gameScene/loaders.ts"
click node_update "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/gameScene/update.ts"
click node_physics "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/physics/ConstraintSystem.ts"
click node_visual "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/visual/GameObject.ts"
click node_resources "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/resources/ResourceMgr.ts"
click node_ui "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/ui/InterfaceManager/index.ts"
click node_viewport "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/ZoomManager.ts"
click node_storage "https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/core/SettingStorage.ts"

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_html,node_app,node_ctr toneBlue
class node_visual,node_resources toneAmber
class node_root,node_controller,node_scene,node_sceneinit,node_loaders,node_update,node_mechanics,node_physics toneMint
class node_ui,node_viewport,node_storage toneRose
class node_levels,node_media toneIndigo
```

## Components

### Browser bootstrap

- [Client entry](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/index.html): HTML entry · `index.html`
- [App bootstrap](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/app.ts): TypeScript bootstrap · `src/app.ts`
- [Game startup](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/ctr.ts): startup module · `src/ctr.ts`

### Engine and resources

- [Canvas visual runtime](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/visual/GameObject.ts): rendering and animation · Provides game objects, camera, timelines, particles, and textures. · `src/visual/GameObject.ts`
- [Resource pipeline](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/resources/ResourceMgr.ts): asset loader · Loads images, JSON, audio, and texture atlases. · `src/resources/ResourceMgr.ts`

### Game scene and simulation

- [Game root controller](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/game/CTRRootController.ts): root controller · `src/game/CTRRootController.ts`
- [Game controller](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/game/GameController.ts): play coordinator · `src/game/GameController.ts`
- [Game scene](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/GameScene.ts): scene assembly · `src/GameScene.ts`
- [Scene initialization](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/gameScene/init.ts): level setup stages · Builds background, candy, animation, UI stars, and reset state. · `src/gameScene/init.ts`
- [Scene loaders](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/gameScene/loaders.ts): authored-data loaders · `src/gameScene/loaders.ts`
- [Frame update](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/gameScene/update.ts): simulation dispatcher · `src/gameScene/update.ts`
- **Scene mechanics**: interaction systems · Handles collisions, cuts, ropes, teleportation, and object lifecycles.
- [Constraint physics](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/physics/ConstraintSystem.ts): custom simulation · `src/physics/ConstraintSystem.ts`

### UI and adaptation

- [Interface manager](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/ui/InterfaceManager/index.ts): menu and panel flow · `src/ui/InterfaceManager/index.ts`
- [Viewport adaptation](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/ZoomManager.ts): canvas scaling · `src/ZoomManager.ts`
- [Settings storage](https://github.com/yell0wsuit/cuttherope-h5dx/blob/main/src/core/SettingStorage.ts): browser persistence · `src/core/SettingStorage.ts`

### Static content

- **Level definitions**: level JSON
- **Media assets**: public assets · Atlases, sound, and video served as static files.

## Connections

- Client entry → App bootstrap: loads
- App bootstrap → Game startup: starts
- Game startup → Game root controller: creates
- Game root controller → Game controller: coordinates
- Game controller → Game scene: runs
- Game scene → Scene initialization: assembles
- Scene initialization → Scene loaders: loads level objects
- Level definitions → Scene loaders: authored input
- Game scene → Frame update: updates each frame
- Frame update → Scene mechanics: dispatches
- Scene mechanics → Constraint physics: simulates constraints
- Game scene → Canvas visual runtime: renders through
- Resource pipeline → Media assets: fetches
- Resource pipeline → Canvas visual runtime: provides textures
- Game root controller → Interface manager: drives game flow
- Interface manager → Settings storage: persists settings
- Game scene → Viewport adaptation: adapts canvas
- Interface manager → Viewport adaptation: scales UI
