How yell0wsuit/cuttherope-h5dx works
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: GameScene.ts Game scene · CTRRootController.ts Game root controller · index.ts Interface manager · ResourceMgr.ts Resource pipeline
Components 18
Browser bootstrap
- Client entry
index.html - App bootstrap
src/app.ts - Game startup
src/ctr.ts
Engine and resources
- Canvas visual runtime · Provides game objects, camera, timelines, particles, and textures.
src/visual/GameObject.ts - Resource pipeline · Loads images, JSON, audio, and texture atlases.
src/resources/ResourceMgr.ts
Game scene and simulation
- Game root controller
src/game/CTRRootController.ts - Game controller
src/game/GameController.ts - Game scene
src/GameScene.ts - Scene initialization · Builds background, candy, animation, UI stars, and reset state.
src/gameScene/init.ts - Scene loaders
src/gameScene/loaders.ts - Frame update
src/gameScene/update.ts - Scene mechanics · Handles collisions, cuts, ropes, teleportation, and object lifecycles.
- Constraint physics
src/physics/ConstraintSystem.ts
UI and adaptation
- Interface manager
src/ui/InterfaceManager/index.ts - Viewport adaptation
src/ZoomManager.ts - Settings storage
src/core/SettingStorage.ts
Static content
- Level definitions
- Media assets · Atlases, sound, and video served as static files.
Connections 18
- 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