# lengyuan1/tower-game architecture

> Architecture diagram of the GitHub repository lengyuan1/tower-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lengyuan1/tower-game
- Repository: https://github.com/lengyuan1/tower-game

## Overview

This is a browser-based 3D tower-stacking game. The documented player workflow is to time a click to stack a moving block; the game aligns it, cuts off overhangs, and increases the challenge as the tower rises. The README also describes ready, playing, ended, and reset states, a requestAnimationFrame render loop, Three.js scene rendering, and GSAP animations for camera motion, falling pieces, and end-game transitions. No source excerpts were provided, so implementation paths and relationships below rely on the README and use index.html only as the available application file.

Main entry points: [`index.html`](https://github.com/lengyuan1/tower-game/blob/main/index.html) (GSAP animations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game logic"]
  node_game_states["Game states<br/>[index.html]"]
  node_stacking["Block stacking<br/>[index.html]"]
  node_alignment["Alignment and cutting<br/>[index.html]"]
  node_difficulty["Rising difficulty<br/>[index.html]"]
end

subgraph group_render["3D rendering"]
  node_render_loop["Render loop<br/>[index.html]"]
  node_three["Three.js scene<br/>[index.html]"]
  node_lighting["Scene lighting<br/>[index.html]"]
  node_camera["Orthographic camera<br/>[index.html]"]
end

subgraph group_animation["Animation"]
  node_gsap["GSAP animations<br/>[index.html]"]
  node_camera_motion["Camera motion<br/>[index.html]"]
  node_falling_blocks["Falling cut pieces<br/>[index.html]"]
  node_end_transition["End transition<br/>[index.html]"]
end

node_player(("Player"))

node_player -->|"times click"| node_stacking
node_stacking -->|"aligns and cuts"| node_alignment
node_alignment -->|"raises challenge"| node_difficulty
node_game_states -->|"controls play"| node_stacking
node_render_loop -->|"renders scene"| node_three
node_three -->|"uses lights"| node_lighting
node_three -->|"uses camera"| node_camera
node_gsap -->|"animates camera"| node_camera_motion
node_gsap -->|"animates falls"| node_falling_blocks
node_gsap -->|"animates ending"| node_end_transition

click node_game_states "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_stacking "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_alignment "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_difficulty "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_render_loop "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_three "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_lighting "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_camera "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_gsap "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_camera_motion "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_falling_blocks "https://github.com/lengyuan1/tower-game/blob/main/index.html"
click node_end_transition "https://github.com/lengyuan1/tower-game/blob/main/index.html"

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_game_states,node_stacking,node_alignment,node_difficulty toneBlue
class node_render_loop,node_three,node_lighting,node_camera toneAmber
class node_gsap,node_camera_motion,node_falling_blocks,node_end_transition toneMint
class node_player toneIndigo
```

## Components

### Game logic

- [Game states](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Block stacking](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Alignment and cutting](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Rising difficulty](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`

### 3D rendering

- [Render loop](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Three.js scene](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Scene lighting](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Orthographic camera](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`

### Animation

- [GSAP animations](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Camera motion](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [Falling cut pieces](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`
- [End transition](https://github.com/lengyuan1/tower-game/blob/main/index.html): `index.html`

### Other components

- **Player**

## Connections

- Player → Block stacking: times click (evidence: `README.md`)
- Block stacking → Alignment and cutting: aligns and cuts (evidence: `README.md`)
- Alignment and cutting → Rising difficulty: raises challenge (evidence: `README.md`)
- Game states → Block stacking: controls play (evidence: `README.md`)
- Render loop → Three.js scene: renders scene (evidence: `README.md`)
- Three.js scene → Scene lighting: uses lights (evidence: `README.md`)
- Three.js scene → Orthographic camera: uses camera (evidence: `README.md`)
- GSAP animations → Camera motion: animates camera (evidence: `README.md`)
- GSAP animations → Falling cut pieces: animates falls (evidence: `README.md`)
- GSAP animations → End transition: animates ending (evidence: `README.md`)
