# sam-nisa/gunting-game architecture

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

- Interactive diagram: https://gitdiagram.com/sam-nisa/gunting-game
- Repository: https://github.com/sam-nisa/gunting-game

## Overview

Metal Fury is a browser-based side-scrolling action game. The player starts and controls a run; the game loop advances gameplay and draws the result, while waves, enemies, weapons, and pickups shape combat. The game also provides a shop, persistent player cosmetics and coins, and high scores/leaderboard backed by Firebase when available. The excerpts show key calls across the runtime, but not the HTML script wiring or every shop and persistence implementation detail; those connections are omitted where unverified.

Main entry points: [`js/game.js`](https://github.com/sam-nisa/gunting-game/blob/main/js/game.js) (Controls and menus), [`js/render.js`](https://github.com/sam-nisa/gunting-game/blob/main/js/render.js) (World simulation), [`js/state.js`](https://github.com/sam-nisa/gunting-game/blob/main/js/state.js) (Game state), [`js/entities.js`](https://github.com/sam-nisa/gunting-game/blob/main/js/entities.js) (Combat and physics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_controls["Controls and menus<br/>[game.js]"]
  node_loop["Game loop<br/>[game.js]"]
  node_state["Game state<br/>[state.js]"]
end

subgraph group_gameplay["Combat and progression"]
  node_combat["Combat and physics<br/>[entities.js]"]
  node_waves["Waves and enemies<br/>[entities.js]"]
  node_simulation["World simulation<br/>[render.js]"]
  node_shop["Shop and rewards<br/>[game.js]"]
  node_archived["Archived game snapshot<br/>[game-full.js]"]
end

subgraph group_presentation["Display and sound"]
  node_drawing["Canvas rendering<br/>[render.js]"]
  node_audio["Audio engine<br/>[audio.js]"]
end

subgraph group_persistence["Player persistence"]
  node_scores["High scores<br/>[game.js]"]
  node_firebase["Firebase auth and data<br/>[firebase-init.js]"]
end

node_player(("Player"))
node_firestore[("Player records")]

node_player -->|"provides input"| node_controls
node_controls -->|"starts loop"| node_loop
node_loop -->|"calls update"| node_simulation
node_loop -->|"calls draw"| node_drawing
node_combat -.->|"uses world state"| node_state
node_waves -->|"uses difficulty"| node_state
node_simulation -.->|"updates state"| node_state
node_simulation -.->|"uses combat entities"| node_combat
node_drawing -.->|"draws game state"| node_state
node_simulation -->|"saves rewards"| node_shop
node_combat -->|"plays effects"| node_audio
node_controls -->|"starts music"| node_audio
node_controls -->|"records scores"| node_scores
node_scores -->|"saves scores"| node_firebase
node_shop -.->|"persists player data"| node_firebase
node_firebase -->|"reads and writes"| node_firestore

click node_controls "https://github.com/sam-nisa/gunting-game/blob/main/js/game.js"
click node_loop "https://github.com/sam-nisa/gunting-game/blob/main/js/game.js"
click node_state "https://github.com/sam-nisa/gunting-game/blob/main/js/state.js"
click node_combat "https://github.com/sam-nisa/gunting-game/blob/main/js/entities.js"
click node_waves "https://github.com/sam-nisa/gunting-game/blob/main/js/entities.js"
click node_simulation "https://github.com/sam-nisa/gunting-game/blob/main/js/render.js"
click node_shop "https://github.com/sam-nisa/gunting-game/blob/main/js/game.js"
click node_drawing "https://github.com/sam-nisa/gunting-game/blob/main/js/render.js"
click node_audio "https://github.com/sam-nisa/gunting-game/blob/main/js/audio.js"
click node_scores "https://github.com/sam-nisa/gunting-game/blob/main/js/game.js"
click node_firebase "https://github.com/sam-nisa/gunting-game/blob/main/js/firebase-init.js"
click node_archived "https://github.com/sam-nisa/gunting-game/blob/main/archive/game-full.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_controls,node_loop,node_state toneBlue
class node_combat,node_waves,node_simulation,node_shop,node_archived,node_firestore toneAmber
class node_drawing,node_audio toneMint
class node_scores,node_firebase toneRose
class node_player toneIndigo
```

## Components

### Game runtime

- [Controls and menus](https://github.com/sam-nisa/gunting-game/blob/main/js/game.js): `js/game.js`
- [Game loop](https://github.com/sam-nisa/gunting-game/blob/main/js/game.js): `js/game.js`
- [Game state](https://github.com/sam-nisa/gunting-game/blob/main/js/state.js): `js/state.js`

### Combat and progression

- [Combat and physics](https://github.com/sam-nisa/gunting-game/blob/main/js/entities.js): `js/entities.js`
- [Waves and enemies](https://github.com/sam-nisa/gunting-game/blob/main/js/entities.js): `js/entities.js`
- [World simulation](https://github.com/sam-nisa/gunting-game/blob/main/js/render.js): `js/render.js`
- [Shop and rewards](https://github.com/sam-nisa/gunting-game/blob/main/js/game.js): `js/game.js`
- [Archived game snapshot](https://github.com/sam-nisa/gunting-game/blob/main/archive/game-full.js): `archive/game-full.js`

### Display and sound

- [Canvas rendering](https://github.com/sam-nisa/gunting-game/blob/main/js/render.js): `js/render.js`
- [Audio engine](https://github.com/sam-nisa/gunting-game/blob/main/js/audio.js): `js/audio.js`

### Player persistence

- [High scores](https://github.com/sam-nisa/gunting-game/blob/main/js/game.js): `js/game.js`
- [Firebase auth and data](https://github.com/sam-nisa/gunting-game/blob/main/js/firebase-init.js): `js/firebase-init.js`

### Other components

- **Player**
- **Player records**

## Connections

- Player → Controls and menus: provides input (evidence: `js/game.js`)
- Controls and menus → Game loop: starts loop (evidence: `js/game.js`)
- Game loop → World simulation: calls update (evidence: `js/game.js`)
- Game loop → Canvas rendering: calls draw (evidence: `js/game.js`)
- Combat and physics → Game state: uses world state
- Waves and enemies → Game state: uses difficulty (evidence: `js/entities.js`)
- World simulation → Game state: updates state
- World simulation → Combat and physics: uses combat entities
- Canvas rendering → Game state: draws game state
- World simulation → Shop and rewards: saves rewards (evidence: `js/render.js`)
- Combat and physics → Audio engine: plays effects (evidence: `js/entities.js`)
- Controls and menus → Audio engine: starts music (evidence: `js/game.js`)
- Controls and menus → High scores: records scores (evidence: `js/game.js`)
- High scores → Firebase auth and data: saves scores (evidence: `js/game.js`)
- Shop and rewards → Firebase auth and data: persists player data
- Firebase auth and data → Player records: reads and writes (evidence: `js/firebase-init.js`)
