# haimni/alien_invasion architecture

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

- Interactive diagram: https://gitdiagram.com/haimni/alien_invasion
- Repository: https://github.com/haimni/alien_invasion

## Overview

Alien Invasion is a Pygame arcade game: the player starts a run, steers a ship, fires at descending alien fleets, and advances through increasingly fast, higher-scoring levels. `alien_invasion.py` coordinates input, updates, collisions, resets, and rendering; the entity modules implement movement and drawing, while game state and settings support lives, score, and difficulty progression. The scoreboard and play button provide the visible interface. The README describes the game at a high level; the graph follows the sampled runtime source and does not infer additional features.

Main entry points: [`alien_invasion.py`](https://github.com/haimni/alien_invasion/blob/main/alien_invasion.py) (Game loop and rules), [`settings.py`](https://github.com/haimni/alien_invasion/blob/main/settings.py) (Game settings), [`ship.py`](https://github.com/haimni/alien_invasion/blob/main/ship.py) (Player ship), [`alien.py`](https://github.com/haimni/alien_invasion/blob/main/alien.py) (Alien sprites)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Game control"]
  node_game["Game loop and rules<br/>[alien_invasion.py]"]
end

subgraph group_entities["Game entities"]
  node_ship["Player ship<br/>[ship.py]"]
  node_bullets["Bullet sprites<br/>[bullet.py]"]
  node_aliens["Alien sprites<br/>[alien.py]"]
  node_ship_image["Ship image<br/>[ship.bmp]"]
  node_alien_image["Alien image<br/>[alien.bmp]"]
end

subgraph group_progress["State and progression"]
  node_settings["Game settings<br/>[settings.py]"]
  node_stats["Game statistics<br/>[game_stats.py]"]
end

subgraph group_ui["Interface"]
  node_scoreboard["Scoreboard<br/>[scoreboard.py]"]
  node_button["Play button<br/>[button.py]"]
end

node_player(("Player"))

node_player -->|"sends input"| node_game
node_game -->|"initializes and adjusts"| node_settings
node_game -->|"resets and updates"| node_stats
node_game -->|"creates and updates"| node_ship
node_game -->|"creates and updates"| node_bullets
node_game -->|"creates and updates"| node_aliens
node_game -->|"updates and draws"| node_scoreboard
node_game -->|"checks and draws"| node_button
node_ship -->|"reads speed"| node_settings
node_bullets -->|"reads firing settings"| node_settings
node_aliens -->|"reads fleet settings"| node_settings
node_scoreboard -->|"reads and records high score"| node_stats
node_scoreboard -->|"reads background"| node_settings
node_ship -->|"loads"| node_ship_image
node_aliens -->|"loads"| node_alien_image

click node_game "https://github.com/haimni/alien_invasion/blob/main/alien_invasion.py"
click node_settings "https://github.com/haimni/alien_invasion/blob/main/settings.py"
click node_stats "https://github.com/haimni/alien_invasion/blob/main/game_stats.py"
click node_ship "https://github.com/haimni/alien_invasion/blob/main/ship.py"
click node_bullets "https://github.com/haimni/alien_invasion/blob/main/bullet.py"
click node_aliens "https://github.com/haimni/alien_invasion/blob/main/alien.py"
click node_scoreboard "https://github.com/haimni/alien_invasion/blob/main/scoreboard.py"
click node_button "https://github.com/haimni/alien_invasion/blob/main/button.py"
click node_ship_image "https://github.com/haimni/alien_invasion/blob/main/images/ship.bmp"
click node_alien_image "https://github.com/haimni/alien_invasion/blob/main/images/alien.bmp"

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_ship,node_bullets,node_aliens,node_ship_image,node_alien_image toneAmber
class node_settings,node_stats toneMint
class node_scoreboard,node_button toneRose
class node_player toneIndigo
```

## Components

### Game control

- [Game loop and rules](https://github.com/haimni/alien_invasion/blob/main/alien_invasion.py): `alien_invasion.py`

### Game entities

- [Player ship](https://github.com/haimni/alien_invasion/blob/main/ship.py): `ship.py`
- [Bullet sprites](https://github.com/haimni/alien_invasion/blob/main/bullet.py): `bullet.py`
- [Alien sprites](https://github.com/haimni/alien_invasion/blob/main/alien.py): `alien.py`
- [Ship image](https://github.com/haimni/alien_invasion/blob/main/images/ship.bmp): `images/ship.bmp`
- [Alien image](https://github.com/haimni/alien_invasion/blob/main/images/alien.bmp): `images/alien.bmp`

### State and progression

- [Game settings](https://github.com/haimni/alien_invasion/blob/main/settings.py): `settings.py`
- [Game statistics](https://github.com/haimni/alien_invasion/blob/main/game_stats.py): `game_stats.py`

### Interface

- [Scoreboard](https://github.com/haimni/alien_invasion/blob/main/scoreboard.py): `scoreboard.py`
- [Play button](https://github.com/haimni/alien_invasion/blob/main/button.py): `button.py`

### Other components

- **Player**

## Connections

- Player → Game loop and rules: sends input
- Game loop and rules → Game settings: initializes and adjusts
- Game loop and rules → Game statistics: resets and updates
- Game loop and rules → Player ship: creates and updates
- Game loop and rules → Bullet sprites: creates and updates
- Game loop and rules → Alien sprites: creates and updates
- Game loop and rules → Scoreboard: updates and draws
- Game loop and rules → Play button: checks and draws
- Player ship → Game settings: reads speed
- Bullet sprites → Game settings: reads firing settings
- Alien sprites → Game settings: reads fleet settings
- Scoreboard → Game statistics: reads and records high score
- Scoreboard → Game settings: reads background
- Player ship → Ship image: loads
- Alien sprites → Alien image: loads
