# voidxh/space-impact-ii architecture

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

- Interactive diagram: https://gitdiagram.com/voidxh/space-impact-ii
- Repository: https://github.com/voidxh/space-impact-ii

## Overview

#### Purpose and Entry Point
A native C implementation of a pixel-perfect Nokia Space Impact clone. Execution begins in `main.c`; the project is built through the Code::Blocks project and platform makefiles: `Space Impact II.cbp`, `Space Impact II.cbp.mak.unix`, and `Space Impact II.cbp.mak.windows`.

#### Game Orchestration
`main.c` owns the application/game loop and coordinates initialization, input-driven state transitions, simulation, rendering, and shutdown. Shared game-state structures and constants form the cross-module contract in `structures.h` and `config.h`.

#### Rendering and UI
`graphics.c` / `graphics.h` provide the graphics boundary used to render gameplay state. `font.c` / `font.h` supply bitmap/text rendering, likely for HUD, menus, scores, and status messages. These modules separate presentation from object, enemy, and projectile simulation.

#### World and Content Loading
Level, scenery, enemy, and object definitions are externalized as numeric `.dat` assets. `scenery.c` / `scenery.h` consume level/world content from `data/levels/0.dat` through `data/levels/5.dat`; object definitions reside under `data/objects/`, such as `data/objects/0.dat` and `data/objects/255.dat`. This data-driven boundary enables level/content changes without changing core simulation code.

#### Enemy Simulation
`enemies.c` / `enemies.h` manage enemy loading, behavior, state updates, and likely enemy/player interactions. Enemy type definitions are stored independently in `data/enemies/`, including `data/enemies/0.dat`, `data/enemies/40.dat`, and sentinel/special IDs such as `data/enemies/255.dat`.

#### Projectile and Collision Flow
`shotlist.c` / `shotlist.h` represent and update active shots/projectiles. The main loop likely advances player/enemy entities, then delegates projectile movement and hit resolution across enemy and scenery/object state. Shared representations in `structures.h` are the critical integration point between these subsystems.

#### Persistence and Audio Boundaries
`saves.c` / `saves.h` isolate persistent progress or score handling from runtime gameplay. `audio.c` / `audio.h` isolate sound-effect/music playback. Neither asset nor service infrastructure is present beyond local files; this is a standalone native game with no web, backend, or cloud dependencies.

#### Primary Control Flow
Startup initializes graphics, audio, saves, and game content; gameplay repeatedly processes input, updates scenery/objects, enemies, and shots, then renders the assembled state and emits audio events. Level and entity data flow inward from `data/levels/`, `data/objects/`, and `data/enemies/`; persistent outcomes flow outward through `saves.c`.

Main entry points: [`main.c`](https://github.com/voidxh/space-impact-ii/blob/master/main.c) (Game loop), [`scenery.c`](https://github.com/voidxh/space-impact-ii/blob/master/scenery.c) (World simulation), [`structures.h`](https://github.com/voidxh/space-impact-ii/blob/master/structures.h) (Shared game state), [`shotlist.c`](https://github.com/voidxh/space-impact-ii/blob/master/shotlist.c) (Projectile simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_main{{"Game loop<br/>orchestrator<br/>[main.c]"}}
  node_contracts["Shared game state<br/>shared contract<br/>[structures.h]"]
  node_config["Game constants<br/>configuration contract<br/>[config.h]"]
  node_scenery["World simulation<br/>gameplay module<br/>[scenery.c]"]
  node_enemies["Enemy simulation<br/>gameplay module<br/>[enemies.c]"]
  node_shots["Projectile simulation<br/>gameplay module<br/>[shotlist.c]"]
  node_saves[("Save persistence<br/>persistence module<br/>[saves.c]")]
end

subgraph group_presentation["Presentation"]
  node_audio["Audio playback<br/>audio module<br/>[audio.c]"]
  node_graphics["Graphics renderer<br/>rendering module<br/>[graphics.c]"]
  node_font["Bitmap text<br/>rendering module<br/>[font.c]"]
end

subgraph group_content["External Content"]
  node_levels["Level data<br/>level assets<br/>[0.dat]"]
  node_objects["Object data<br/>object assets<br/>[0.dat]"]
  node_enemies_data["Enemy data<br/>enemy assets<br/>[0.dat]"]
end

node_main -->|"owns state"| node_contracts
node_main -->|"uses constants"| node_config
node_main -->|"updates world"| node_scenery
node_main -->|"updates enemies"| node_enemies
node_main -->|"updates shots"| node_shots
node_main -->|"renders state"| node_graphics
node_main -->|"emits sound events"| node_audio
node_main -->|"loads and saves outcomes"| node_saves
node_graphics -->|"renders text"| node_font
node_scenery -->|"loads"| node_levels
node_scenery -->|"loads"| node_objects
node_enemies -->|"loads"| node_enemies_data
node_scenery -->|"reads and writes state"| node_contracts
node_enemies -->|"reads and writes state"| node_contracts
node_shots -->|"resolves hits against state"| node_contracts
node_shots -->|"applies enemy hits"| node_enemies
node_shots -->|"checks world hits"| node_scenery
node_graphics -->|"reads display state"| node_contracts

click node_main "https://github.com/voidxh/space-impact-ii/blob/master/main.c"
click node_contracts "https://github.com/voidxh/space-impact-ii/blob/master/structures.h"
click node_config "https://github.com/voidxh/space-impact-ii/blob/master/config.h"
click node_scenery "https://github.com/voidxh/space-impact-ii/blob/master/scenery.c"
click node_enemies "https://github.com/voidxh/space-impact-ii/blob/master/enemies.c"
click node_shots "https://github.com/voidxh/space-impact-ii/blob/master/shotlist.c"
click node_saves "https://github.com/voidxh/space-impact-ii/blob/master/saves.c"
click node_audio "https://github.com/voidxh/space-impact-ii/blob/master/audio.c"
click node_graphics "https://github.com/voidxh/space-impact-ii/blob/master/graphics.c"
click node_font "https://github.com/voidxh/space-impact-ii/blob/master/font.c"
click node_levels "https://github.com/voidxh/space-impact-ii/blob/master/data/levels/0.dat"
click node_objects "https://github.com/voidxh/space-impact-ii/blob/master/data/objects/0.dat"
click node_enemies_data "https://github.com/voidxh/space-impact-ii/blob/master/data/enemies/0.dat"

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_contracts,node_config,node_scenery,node_enemies,node_shots,node_saves toneBlue
class node_audio,node_graphics,node_font toneAmber
class node_levels,node_objects,node_enemies_data toneMint
```

## Components

### Game Runtime

- [Game loop](https://github.com/voidxh/space-impact-ii/blob/master/main.c): orchestrator · Initializes, advances, renders, and shuts down the game. · `main.c`
- [Shared game state](https://github.com/voidxh/space-impact-ii/blob/master/structures.h): shared contract · State structures and constants shared across gameplay modules. · `structures.h`
- [Game constants](https://github.com/voidxh/space-impact-ii/blob/master/config.h): configuration contract · `config.h`
- [World simulation](https://github.com/voidxh/space-impact-ii/blob/master/scenery.c): gameplay module · Loads and updates level scenery and objects. · `scenery.c`
- [Enemy simulation](https://github.com/voidxh/space-impact-ii/blob/master/enemies.c): gameplay module · Loads and updates enemy behavior and interactions. · `enemies.c`
- [Projectile simulation](https://github.com/voidxh/space-impact-ii/blob/master/shotlist.c): gameplay module · Updates active shots and resolves hits. · `shotlist.c`
- [Save persistence](https://github.com/voidxh/space-impact-ii/blob/master/saves.c): persistence module · Reads and writes local game progress or scores. · `saves.c`

### Presentation

- [Audio playback](https://github.com/voidxh/space-impact-ii/blob/master/audio.c): audio module · `audio.c`
- [Graphics renderer](https://github.com/voidxh/space-impact-ii/blob/master/graphics.c): rendering module · Renders assembled gameplay state. · `graphics.c`
- [Bitmap text](https://github.com/voidxh/space-impact-ii/blob/master/font.c): rendering module · Draws HUD, menus, and status text. · `font.c`

### External Content

- [Level data](https://github.com/voidxh/space-impact-ii/blob/master/data/levels/0.dat): level assets · Numeric world definitions for levels 0 through 5. · `data/levels/0.dat`
- [Object data](https://github.com/voidxh/space-impact-ii/blob/master/data/objects/0.dat): object assets · Numeric object definitions, including special IDs. · `data/objects/0.dat`
- [Enemy data](https://github.com/voidxh/space-impact-ii/blob/master/data/enemies/0.dat): enemy assets · Numeric enemy type definitions, including special IDs. · `data/enemies/0.dat`

## Connections

- Game loop → Shared game state: owns state
- Game loop → Game constants: uses constants
- Game loop → World simulation: updates world
- Game loop → Enemy simulation: updates enemies
- Game loop → Projectile simulation: updates shots
- Game loop → Graphics renderer: renders state
- Game loop → Audio playback: emits sound events
- Game loop → Save persistence: loads and saves outcomes
- Graphics renderer → Bitmap text: renders text
- World simulation → Level data: loads
- World simulation → Object data: loads
- Enemy simulation → Enemy data: loads
- World simulation → Shared game state: reads and writes state
- Enemy simulation → Shared game state: reads and writes state
- Projectile simulation → Shared game state: resolves hits against state
- Projectile simulation → Enemy simulation: applies enemy hits
- Projectile simulation → World simulation: checks world hits
- Graphics renderer → Shared game state: reads display state
