# heminados/space_invaders architecture

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

- Interactive diagram: https://gitdiagram.com/heminados/space_invaders
- Repository: https://github.com/heminados/space_invaders

## Overview

This is a Turtle/Pygame Space Invaders game. The player starts from a title screen, enters a name, and the game loop manages movement, enemy waves, shooting, collisions, bonuses, scoring, and level progression. On victory or defeat, the game saves a high score and displays a results screen with a restart option. The graph reflects the sampled runtime code and README (which is empty); unsampled portions of the game loop may contain additional details.

Main entry points: [`game/game.py`](https://github.com/heminados/space_invaders/blob/main/game/game.py) (Game Loop), [`main.py`](https://github.com/heminados/space_invaders/blob/main/main.py) (Launch and Music), [`entities/entity.py`](https://github.com/heminados/space_invaders/blob/main/entities/entity.py) (Entity Base), [`ui/screens.py`](https://github.com/heminados/space_invaders/blob/main/ui/screens.py) (Start Screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry_ui["Entry and Screens"]
  node_main["Launch and Music<br/>[main.py]"]
  node_start_screen["Start Screen<br/>[screens.py]"]
end

subgraph group_gameplay["Gameplay Control"]
  node_game["Game Loop<br/>[game.py]"]
  node_levels["Level Manager<br/>[level_manager.py]"]
  node_collision["Collision Check<br/>[collision.py]"]
end

subgraph group_entities["Game Entities"]
  node_entity["Entity Base<br/>[entity.py]"]
  node_player_ship["Player Ship<br/>[player.py]"]
  node_enemy["Enemy<br/>[enemy.py]"]
  node_bullet["Bullet<br/>[bullet.py]"]
  node_bonus["Bonus<br/>[bonus.py]"]
end

subgraph group_display["Scoring and Results"]
  node_scoreboard["Scoreboard<br/>[scoreboard.py]"]
  node_highscores[("High Scores<br/>[game.py]")]
  node_result_screens["Result Screens<br/>[screens.py]"]
end

node_player(("Player"))

node_player -->|"starts game"| node_start_screen
node_main -->|"creates"| node_start_screen
node_main -->|"launches"| node_game
node_start_screen -->|"calls start callback"| node_main
node_game -->|"gets waves"| node_levels
node_levels -->|"creates enemies"| node_enemy
node_game -->|"creates"| node_player_ship
node_game -->|"creates shots"| node_bullet
node_game -->|"spawns bonuses"| node_bonus
node_game -->|"checks hits"| node_collision
node_player_ship -->|"extends"| node_entity
node_enemy -->|"extends"| node_entity
node_bullet -->|"extends"| node_entity
node_bonus -->|"extends"| node_entity
node_game -->|"updates"| node_scoreboard
node_game -->|"loads and saves"| node_highscores
node_game -->|"shows outcome"| node_result_screens
node_result_screens -->|"restart callback"| node_main

click node_main "https://github.com/heminados/space_invaders/blob/main/main.py"
click node_start_screen "https://github.com/heminados/space_invaders/blob/main/ui/screens.py"
click node_game "https://github.com/heminados/space_invaders/blob/main/game/game.py"
click node_levels "https://github.com/heminados/space_invaders/blob/main/game/level_manager.py"
click node_collision "https://github.com/heminados/space_invaders/blob/main/game/collision.py"
click node_entity "https://github.com/heminados/space_invaders/blob/main/entities/entity.py"
click node_player_ship "https://github.com/heminados/space_invaders/blob/main/entities/player.py"
click node_enemy "https://github.com/heminados/space_invaders/blob/main/entities/enemy.py"
click node_bullet "https://github.com/heminados/space_invaders/blob/main/entities/bullet.py"
click node_bonus "https://github.com/heminados/space_invaders/blob/main/entities/bonus.py"
click node_scoreboard "https://github.com/heminados/space_invaders/blob/main/ui/scoreboard.py"
click node_highscores "https://github.com/heminados/space_invaders/blob/main/game/game.py"
click node_result_screens "https://github.com/heminados/space_invaders/blob/main/ui/screens.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_main,node_start_screen toneBlue
class node_game,node_levels,node_collision toneAmber
class node_entity,node_player_ship,node_enemy,node_bullet,node_bonus toneMint
class node_scoreboard,node_highscores,node_result_screens toneRose
class node_player toneIndigo
```

## Components

### Entry and Screens

- [Launch and Music](https://github.com/heminados/space_invaders/blob/main/main.py): `main.py`
- [Start Screen](https://github.com/heminados/space_invaders/blob/main/ui/screens.py): `ui/screens.py`

### Gameplay Control

- [Game Loop](https://github.com/heminados/space_invaders/blob/main/game/game.py): `game/game.py`
- [Level Manager](https://github.com/heminados/space_invaders/blob/main/game/level_manager.py): `game/level_manager.py`
- [Collision Check](https://github.com/heminados/space_invaders/blob/main/game/collision.py): `game/collision.py`

### Game Entities

- [Entity Base](https://github.com/heminados/space_invaders/blob/main/entities/entity.py): `entities/entity.py`
- [Player Ship](https://github.com/heminados/space_invaders/blob/main/entities/player.py): `entities/player.py`
- [Enemy](https://github.com/heminados/space_invaders/blob/main/entities/enemy.py): `entities/enemy.py`
- [Bullet](https://github.com/heminados/space_invaders/blob/main/entities/bullet.py): `entities/bullet.py`
- [Bonus](https://github.com/heminados/space_invaders/blob/main/entities/bonus.py): `entities/bonus.py`

### Scoring and Results

- [Scoreboard](https://github.com/heminados/space_invaders/blob/main/ui/scoreboard.py): `ui/scoreboard.py`
- [High Scores](https://github.com/heminados/space_invaders/blob/main/game/game.py): `game/game.py`
- [Result Screens](https://github.com/heminados/space_invaders/blob/main/ui/screens.py): `ui/screens.py`

### Other components

- **Player**

## Connections

- Player → Start Screen: starts game
- Launch and Music → Start Screen: creates (evidence: `main.py`)
- Launch and Music → Game Loop: launches (evidence: `main.py`)
- Start Screen → Launch and Music: calls start callback (evidence: `ui/screens.py`)
- Game Loop → Level Manager: gets waves (evidence: `game/game.py`)
- Level Manager → Enemy: creates enemies (evidence: `game/level_manager.py`)
- Game Loop → Player Ship: creates (evidence: `game/game.py`)
- Game Loop → Bullet: creates shots (evidence: `game/game.py`)
- Game Loop → Bonus: spawns bonuses (evidence: `game/game.py`)
- Game Loop → Collision Check: checks hits (evidence: `game/game.py`)
- Player Ship → Entity Base: extends (evidence: `entities/player.py`)
- Enemy → Entity Base: extends (evidence: `entities/enemy.py`)
- Bullet → Entity Base: extends (evidence: `entities/bullet.py`)
- Bonus → Entity Base: extends (evidence: `entities/bonus.py`)
- Game Loop → Scoreboard: updates (evidence: `game/game.py`)
- Game Loop → High Scores: loads and saves (evidence: `game/game.py`)
- Game Loop → Result Screens: shows outcome (evidence: `game/game.py`)
- Result Screens → Launch and Music: restart callback (evidence: `main.py`)
