# dij0/qix_game architecture

> Architecture diagram of the GitHub repository dij0/qix_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/dij0/qix_game
- Repository: https://github.com/dij0/qix_game

## Overview

PyGame Xonix is a real-time territory-capture game. The player leaves the safe border to draw a trail; when the trail reconnects, the game captures territory, awards progress, and advances levels with changing difficulty and up to three lives. Game.py coordinates input, updates, collisions, menus, and level state. Polygon.py handles the territory mask and fill algorithm, while the inverse mask supports ghost-ball movement. Relationships below are grounded in the sampled source and README; the game loop is the central coordinator.

Main entry points: [`Game.py`](https://github.com/dij0/qix_game/blob/master/Game.py) (Game coordinator), [`Polygon.py`](https://github.com/dij0/qix_game/blob/master/Polygon.py) (Territory capture), [`Ball.py`](https://github.com/dij0/qix_game/blob/master/Ball.py) (Moving balls), [`Player.py`](https://github.com/dij0/qix_game/blob/master/Player.py) (Player trail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Game loop"]
  node_game["Game coordinator<br/>[Game.py]"]
end

subgraph group_entities["Playfield entities"]
  node_player["Player trail<br/>[Player.py]"]
  node_territory["Territory capture<br/>[Polygon.py]"]
  node_inverse["Inverse mask<br/>[InversePolygon.py]"]
  node_balls["Moving balls<br/>[Ball.py]"]
end

subgraph group_interface["Controls and menu"]
  node_menu["Menu<br/>[Button.py]"]
  node_button["Menu buttons<br/>[Button.py]"]
end

node_user(("Player"))

node_user -->|"plays"| node_game
node_game -->|"handles input"| node_player
node_game -->|"updates"| node_player
node_game -->|"tracks progress"| node_territory
node_game -->|"updates"| node_balls
node_game -->|"handles clicks"| node_menu
node_player -->|"draws capture"| node_territory
node_balls -->|"checks collisions"| node_territory
node_balls -->|"checks ghost collisions"| node_inverse
node_territory -->|"updates mask"| node_inverse
node_menu -->|"shows and dispatches"| node_button

click node_player "https://github.com/dij0/qix_game/blob/master/Player.py"
click node_territory "https://github.com/dij0/qix_game/blob/master/Polygon.py"
click node_inverse "https://github.com/dij0/qix_game/blob/master/InversePolygon.py"
click node_balls "https://github.com/dij0/qix_game/blob/master/Ball.py"
click node_game "https://github.com/dij0/qix_game/blob/master/Game.py"
click node_menu "https://github.com/dij0/qix_game/blob/master/Button.py"
click node_button "https://github.com/dij0/qix_game/blob/master/Button.py"

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 toneBlue
class node_player,node_territory,node_inverse,node_balls toneAmber
class node_menu,node_button toneMint
class node_user toneIndigo
```

## Components

### Game loop

- [Game coordinator](https://github.com/dij0/qix_game/blob/master/Game.py): `Game.py`

### Playfield entities

- [Player trail](https://github.com/dij0/qix_game/blob/master/Player.py): `Player.py`
- [Territory capture](https://github.com/dij0/qix_game/blob/master/Polygon.py): `Polygon.py`
- [Inverse mask](https://github.com/dij0/qix_game/blob/master/InversePolygon.py): `InversePolygon.py`
- [Moving balls](https://github.com/dij0/qix_game/blob/master/Ball.py): `Ball.py`

### Controls and menu

- [Menu](https://github.com/dij0/qix_game/blob/master/Button.py): `Button.py`
- [Menu buttons](https://github.com/dij0/qix_game/blob/master/Button.py): `Button.py`

### Other components

- **Player**

## Connections

- Player → Game coordinator: plays (evidence: `README.md`)
- Game coordinator → Player trail: handles input (evidence: `Game.py`)
- Game coordinator → Player trail: updates (evidence: `Game.py`)
- Game coordinator → Territory capture: tracks progress (evidence: `Game.py`)
- Game coordinator → Moving balls: updates (evidence: `Game.py`)
- Game coordinator → Menu: handles clicks (evidence: `Game.py`)
- Player trail → Territory capture: draws capture (evidence: `Player.py`)
- Moving balls → Territory capture: checks collisions (evidence: `Ball.py`)
- Moving balls → Inverse mask: checks ghost collisions (evidence: `Ball.py`)
- Territory capture → Inverse mask: updates mask (evidence: `Polygon.py`)
- Menu → Menu buttons: shows and dispatches (evidence: `Button.py`)
