# attreyabhatt/space-invaders-pygame architecture

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

- Interactive diagram: https://gitdiagram.com/attreyabhatt/space-invaders-pygame
- Repository: https://github.com/attreyabhatt/space-invaders-pygame

## Overview

This repository is a small Pygame space-invaders game. The player uses keyboard input to move and fire; the game loop updates enemies and the projectile, detects hits, updates the score, and renders the scene. Audio files provide background music and gameplay effects. The implementation is concentrated in main.py; the graph separates its runtime responsibilities, not separate modules. The tree lists only audio assets, so image and font dependencies referenced in code are not represented as repository nodes.

Main entry points: [`main.py`](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py) (Game loop), [`background.wav`](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/background.wav) (Background music), [`laser.wav`](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/laser.wav) (Laser effect), [`explosion.wav`](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/explosion.wav) (Explosion effect)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Gameplay"]
  node_loop["Game loop<br/>[main.py]"]
  node_controls["Keyboard controls<br/>[main.py]"]
  node_enemies["Enemy movement<br/>[main.py]"]
  node_projectile["Projectile collision<br/>[main.py]"]
  node_score["Score and game over<br/>[main.py]"]
end

subgraph group_presentation["Presentation"]
  node_rendering["Scene rendering<br/>[main.py]"]
end

subgraph group_audio["Audio"]
  node_music["Background music<br/>[background.wav]"]
  node_laser["Laser effect<br/>[laser.wav]"]
  node_explosion["Explosion effect<br/>[explosion.wav]"]
end

node_player(("Player"))
node_pygame["Pygame runtime"]

node_player -->|"plays through"| node_loop
node_loop -->|"handles input"| node_controls
node_loop -->|"updates"| node_enemies
node_loop -->|"checks hits"| node_projectile
node_loop -->|"updates and displays"| node_score
node_loop -->|"draws scene"| node_rendering
node_loop -->|"uses"| node_pygame
node_loop -->|"plays"| node_music
node_loop -->|"plays on firing"| node_laser
node_loop -->|"plays on hit"| node_explosion

click node_loop "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py"
click node_controls "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py"
click node_enemies "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py"
click node_projectile "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py"
click node_score "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py"
click node_rendering "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py"
click node_music "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/background.wav"
click node_laser "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/laser.wav"
click node_explosion "https://github.com/attreyabhatt/space-invaders-pygame/blob/master/explosion.wav"

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_loop,node_controls,node_enemies,node_projectile,node_score toneBlue
class node_rendering toneAmber
class node_music,node_laser,node_explosion toneMint
class node_player,node_pygame toneIndigo
```

## Components

### Gameplay

- [Game loop](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py): `main.py`
- [Keyboard controls](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py): `main.py`
- [Enemy movement](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py): `main.py`
- [Projectile collision](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py): `main.py`
- [Score and game over](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py): `main.py`

### Presentation

- [Scene rendering](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/main.py): `main.py`

### Audio

- [Background music](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/background.wav): `background.wav`
- [Laser effect](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/laser.wav): `laser.wav`
- [Explosion effect](https://github.com/attreyabhatt/space-invaders-pygame/blob/master/explosion.wav): `explosion.wav`

### Other components

- **Player**
- **Pygame runtime**

## Connections

- Player → Game loop: plays through (evidence: `main.py`)
- Game loop → Keyboard controls: handles input (evidence: `main.py`)
- Game loop → Enemy movement: updates (evidence: `main.py`)
- Game loop → Projectile collision: checks hits (evidence: `main.py`)
- Game loop → Score and game over: updates and displays (evidence: `main.py`)
- Game loop → Scene rendering: draws scene (evidence: `main.py`)
- Game loop → Pygame runtime: uses (evidence: `main.py`)
- Game loop → Background music: plays (evidence: `main.py`)
- Game loop → Laser effect: plays on firing (evidence: `main.py`)
- Game loop → Explosion effect: plays on hit (evidence: `main.py`)
