# prof-lucapulga/spaceinvaders architecture

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

- Interactive diagram: https://gitdiagram.com/prof-lucapulga/spaceinvaders
- Repository: https://github.com/prof-lucapulga/spaceinvaders

## Overview

SpaceInvaders is a browser-based arcade game. The player moves and fires through keyboard input; the main animation loop updates and draws game objects, while alien waves and collisions drive level completion, upgrades, victory, or game over. The graph covers the sampled runtime code and README-documented controls and progression; assets are rendered by the game, but their individual files were not present in the supplied tree.

Main entry points: [`main.js`](https://github.com/prof-lucapulga/spaceinvaders/blob/main/main.js) (Game loop), [`scripts/player.js`](https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/player.js) (Player), [`scripts/enemy.js`](https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/enemy.js) (Alien waves), [`scripts/engine.js`](https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/engine.js) (Game objects)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_objects["Game objects<br/>[engine.js]"]
  node_loop["Game loop<br/>[main.js]"]
end

subgraph group_entities["Game entities"]
  node_player["Player<br/>[player.js]"]
  node_aliens["Alien waves<br/>[enemy.js]"]
  node_bullets["Projectiles<br/>[bullet.js]"]
end

subgraph group_progression["Player progression"]
  node_stage["Input and upgrades<br/>[ministage.js]"]
end

node_keyboard(("Player controls"))

node_keyboard -->|"sends keys"| node_loop
node_loop -->|"dispatches input"| node_player
node_loop -->|"creates waves"| node_aliens
node_loop -->|"updates and draws"| node_objects
node_player -->|"maps input, upgrades"| node_stage
node_player -->|"fires"| node_bullets
node_aliens -->|"fires"| node_bullets
node_player -->|"inherits"| node_objects
node_aliens -->|"inherits"| node_objects
node_bullets -->|"inherits; checks collisions"| node_objects
node_loop -->|"upgrades on level"| node_player
node_loop -->|"checks wave completion"| node_aliens

click node_player "https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/player.js"
click node_aliens "https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/enemy.js"
click node_bullets "https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/bullet.js"
click node_objects "https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/engine.js"
click node_loop "https://github.com/prof-lucapulga/spaceinvaders/blob/main/main.js"
click node_stage "https://github.com/prof-lucapulga/spaceinvaders/blob/main/ministage.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_objects,node_loop toneBlue
class node_player,node_aliens,node_bullets toneAmber
class node_stage toneMint
class node_keyboard toneIndigo
```

## Components

### Game runtime

- [Game objects](https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/engine.js): `scripts/engine.js`
- [Game loop](https://github.com/prof-lucapulga/spaceinvaders/blob/main/main.js): `main.js`

### Game entities

- [Player](https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/player.js): `scripts/player.js`
- [Alien waves](https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/enemy.js): `scripts/enemy.js`
- [Projectiles](https://github.com/prof-lucapulga/spaceinvaders/blob/main/scripts/bullet.js): `scripts/bullet.js`

### Player progression

- [Input and upgrades](https://github.com/prof-lucapulga/spaceinvaders/blob/main/ministage.js): `ministage.js`

### Other components

- **Player controls**

## Connections

- Player controls → Game loop: sends keys (evidence: `main.js`)
- Game loop → Player: dispatches input (evidence: `main.js`)
- Game loop → Alien waves: creates waves (evidence: `main.js`)
- Game loop → Game objects: updates and draws (evidence: `main.js`)
- Player → Input and upgrades: maps input, upgrades (evidence: `scripts/player.js`)
- Player → Projectiles: fires (evidence: `scripts/player.js`)
- Alien waves → Projectiles: fires (evidence: `scripts/enemy.js`)
- Player → Game objects: inherits (evidence: `scripts/player.js`)
- Alien waves → Game objects: inherits (evidence: `scripts/enemy.js`)
- Projectiles → Game objects: inherits; checks collisions (evidence: `scripts/bullet.js`)
- Game loop → Player: upgrades on level (evidence: `main.js`)
- Game loop → Alien waves: checks wave completion (evidence: `main.js`)
