# siapmn/tower_game architecture

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

- Interactive diagram: https://gitdiagram.com/siapmn/tower_game
- Repository: https://github.com/siapmn/tower_game

## Overview

Tower Building Game is a browser-based Canvas stacking game. A player starts a round and taps to release swinging blocks; the game resolves placement, updates floors, score, and remaining lives, and ends after three failures. The main runtime entry configures the engine, game objects, rendering, and touch input. Separate components handle background and scenery, block physics, and scoring/rule callbacks. The README documents configurable dimensions, sound, scoring, motion functions, and result hooks. Edges reflect the entry-point wiring and sampled calls; unsampled integrations are not inferred.

Main entry points: [`src/index.js`](https://github.com/siapmn/tower_game/blob/master/src/index.js) (Game Setup), [`src/block.js`](https://github.com/siapmn/tower_game/blob/master/src/block.js) (Block Physics), [`src/animateFuncs.js`](https://github.com/siapmn/tower_game/blob/master/src/animateFuncs.js) (Game Animation), [`src/utils.js`](https://github.com/siapmn/tower_game/blob/master/src/utils.js) (Touch Input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_entry["Game Setup<br/>[index.js]"]
  node_engine["Canvas Engine"]
  node_input["Touch Input<br/>[utils.js]"]
  node_animation["Game Animation<br/>[animateFuncs.js]"]
end

subgraph group_gameplay["Stacking Gameplay"]
  node_blocks["Block Physics<br/>[block.js]"]
  node_line["Landing Line<br/>[line.js]"]
  node_hook["Swinging Hook<br/>[hook.js]"]
  node_tutorial["Tap Tutorial<br/>[tutorial.js]"]
end

subgraph group_scene["Canvas Scene"]
  node_background["Background<br/>[background.js]"]
  node_clouds["Cloud Scenery<br/>[cloud.js]"]
  node_flights["Flight Effects<br/>[flight.js]"]
  node_rendering["Score Display<br/>[animateFuncs.js]"]
end

subgraph group_rules["Rules And State"]
  node_scoring["Score And Lives<br/>[utils.js]"]
  node_rules["Game Rules<br/>[constant.js]"]
end

node_player(("Player"))

node_player -.->|"starts game"| node_entry
node_entry -->|"creates engine"| node_engine
node_entry -->|"registers touch"| node_input
node_player -.->|"taps to drop"| node_input
node_entry -->|"sets animations"| node_animation
node_entry -->|"sets background"| node_background
node_entry -->|"registers instance"| node_line
node_entry -->|"registers instance"| node_hook
node_entry -->|"registers instances"| node_clouds
node_entry -->|"adds tutorial"| node_tutorial
node_input -->|"updates drop state"| node_blocks
node_animation -->|"creates blocks"| node_blocks
node_animation -->|"adds effects"| node_flights
node_blocks -->|"checks collision"| node_line
node_blocks -->|"updates outcomes"| node_scoring
node_blocks -->|"reads game state"| node_rules
node_scoring -->|"reads options"| node_rules
node_animation -->|"draws status"| node_rendering

click node_entry "https://github.com/siapmn/tower_game/blob/master/src/index.js"
click node_input "https://github.com/siapmn/tower_game/blob/master/src/utils.js"
click node_animation "https://github.com/siapmn/tower_game/blob/master/src/animateFuncs.js"
click node_blocks "https://github.com/siapmn/tower_game/blob/master/src/block.js"
click node_line "https://github.com/siapmn/tower_game/blob/master/src/line.js"
click node_hook "https://github.com/siapmn/tower_game/blob/master/src/hook.js"
click node_tutorial "https://github.com/siapmn/tower_game/blob/master/src/tutorial.js"
click node_scoring "https://github.com/siapmn/tower_game/blob/master/src/utils.js"
click node_rules "https://github.com/siapmn/tower_game/blob/master/src/constant.js"
click node_background "https://github.com/siapmn/tower_game/blob/master/src/background.js"
click node_clouds "https://github.com/siapmn/tower_game/blob/master/src/cloud.js"
click node_flights "https://github.com/siapmn/tower_game/blob/master/src/flight.js"
click node_rendering "https://github.com/siapmn/tower_game/blob/master/src/animateFuncs.js"

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_entry,node_engine,node_input,node_animation toneBlue
class node_blocks,node_line,node_hook,node_tutorial toneAmber
class node_background,node_clouds,node_flights,node_rendering toneMint
class node_scoring,node_rules toneRose
class node_player toneIndigo
```

## Components

### Game Runtime

- [Game Setup](https://github.com/siapmn/tower_game/blob/master/src/index.js): `src/index.js`
- **Canvas Engine**
- [Touch Input](https://github.com/siapmn/tower_game/blob/master/src/utils.js): `src/utils.js`
- [Game Animation](https://github.com/siapmn/tower_game/blob/master/src/animateFuncs.js): `src/animateFuncs.js`

### Stacking Gameplay

- [Block Physics](https://github.com/siapmn/tower_game/blob/master/src/block.js): `src/block.js`
- [Landing Line](https://github.com/siapmn/tower_game/blob/master/src/line.js): `src/line.js`
- [Swinging Hook](https://github.com/siapmn/tower_game/blob/master/src/hook.js): `src/hook.js`
- [Tap Tutorial](https://github.com/siapmn/tower_game/blob/master/src/tutorial.js): `src/tutorial.js`

### Canvas Scene

- [Background](https://github.com/siapmn/tower_game/blob/master/src/background.js): `src/background.js`
- [Cloud Scenery](https://github.com/siapmn/tower_game/blob/master/src/cloud.js): `src/cloud.js`
- [Flight Effects](https://github.com/siapmn/tower_game/blob/master/src/flight.js): `src/flight.js`
- [Score Display](https://github.com/siapmn/tower_game/blob/master/src/animateFuncs.js): `src/animateFuncs.js`

### Rules And State

- [Score And Lives](https://github.com/siapmn/tower_game/blob/master/src/utils.js): `src/utils.js`
- [Game Rules](https://github.com/siapmn/tower_game/blob/master/src/constant.js): `src/constant.js`

### Other components

- **Player**

## Connections

- Player → Game Setup: starts game (evidence: `README.md`)
- Game Setup → Canvas Engine: creates engine (evidence: `src/index.js`)
- Game Setup → Touch Input: registers touch (evidence: `src/index.js`)
- Player → Touch Input: taps to drop
- Game Setup → Game Animation: sets animations (evidence: `src/index.js`)
- Game Setup → Background: sets background (evidence: `src/index.js`)
- Game Setup → Landing Line: registers instance (evidence: `src/index.js`)
- Game Setup → Swinging Hook: registers instance (evidence: `src/index.js`)
- Game Setup → Cloud Scenery: registers instances (evidence: `src/index.js`)
- Game Setup → Tap Tutorial: adds tutorial (evidence: `src/index.js`)
- Touch Input → Block Physics: updates drop state (evidence: `src/utils.js`)
- Game Animation → Block Physics: creates blocks (evidence: `src/animateFuncs.js`)
- Game Animation → Flight Effects: adds effects (evidence: `src/animateFuncs.js`)
- Block Physics → Landing Line: checks collision (evidence: `src/block.js`)
- Block Physics → Score And Lives: updates outcomes (evidence: `src/block.js`)
- Block Physics → Game Rules: reads game state (evidence: `src/block.js`)
- Score And Lives → Game Rules: reads options (evidence: `src/utils.js`)
- Game Animation → Score Display: draws status (evidence: `src/animateFuncs.js`)
