# austridg/rad-2d architecture

> Architecture diagram of the GitHub repository austridg/rad-2d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/austridg/rad-2d
- Repository: https://github.com/austridg/rad-2d

## Overview

RAD-2D is a C++17 raylib wrapper for 2D drawing and animation. The principal workflow is to load textures and fonts, define animations in a shared registry, attach those assets and animations to drawables, then call each drawable’s draw method in the game’s raylib frame loop. Other capabilities include scrolling backgrounds, text effects and typewriter reveals, composite UI, and tilemaps with animated tiles. Asset implementation and parts of drawable rendering were not sampled, so some links are documented rather than source-verified.

Main entry points: [`draw/draw.cpp`](https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp) (Animated drawable base), [`tiles/tiles.cpp`](https://github.com/austridg/rad-2d/blob/master/tiles/tiles.cpp) (Tilemap), [`animation/animation.cpp`](https://github.com/austridg/rad-2d/blob/master/animation/animation.cpp) (Animation registry), [`assets/assets.cpp`](https://github.com/austridg/rad-2d/blob/master/assets/assets.cpp) (Texture and font registries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_assets["Asset management"]
  node_registries["Texture and font registries<br/>[assets.cpp]"]
end

subgraph group_animation["Animation"]
  node_animdef["Animation definitions<br/>[animation.cpp]"]
  node_animregistry[("Animation registry<br/>[animation.cpp]")]
  node_animstate["Animation state<br/>[animation.cpp]"]
end

subgraph group_drawing["Drawing"]
  node_animated["Animated drawable base<br/>[draw.cpp]"]
  node_sprite["Sprite<br/>[draw.cpp]"]
  node_background["Background<br/>[draw.cpp]"]
  node_text["Text<br/>[draw.cpp]"]
  node_ui["UI element<br/>[draw.cpp]"]
end

subgraph group_tiles["Tilemaps"]
  node_tileset[("Tile set<br/>[tiles.cpp]")]
  node_tilemap["Tilemap<br/>[tiles.cpp]"]
end

node_game(("Game application"))
node_raylib["raylib"]

node_game -->|"loads assets"| node_registries
node_game -->|"defines animations"| node_animdef
node_animdef -->|"registers"| node_animregistry
node_game -->|"configures and draws"| node_sprite
node_game -->|"draws"| node_background
node_game -->|"draws"| node_text
node_game -->|"draws"| node_ui
node_game -->|"draws"| node_tilemap
node_animated -->|"fetches animation"| node_animregistry
node_animated -->|"sets playback"| node_animstate
node_sprite -->|"inherits"| node_animated
node_background -->|"inherits"| node_animated
node_ui -->|"inherits"| node_animated
node_ui -->|"draws attached text"| node_text
node_tileset -->|"fetches animation"| node_animregistry
node_tileset -->|"advances animated tiles"| node_animstate
node_tilemap -->|"looks up tiles"| node_tileset
node_registries -.->|"manages assets"| node_raylib
node_sprite -.->|"renders"| node_raylib
node_background -->|"renders"| node_raylib
node_text -->|"renders glyphs"| node_raylib
node_ui -->|"renders"| node_raylib
node_tilemap -->|"renders tiles"| node_raylib

click node_registries "https://github.com/austridg/rad-2d/blob/master/assets/assets.cpp"
click node_animdef "https://github.com/austridg/rad-2d/blob/master/animation/animation.cpp"
click node_animregistry "https://github.com/austridg/rad-2d/blob/master/animation/animation.cpp"
click node_animstate "https://github.com/austridg/rad-2d/blob/master/animation/animation.cpp"
click node_animated "https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp"
click node_sprite "https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp"
click node_background "https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp"
click node_text "https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp"
click node_ui "https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp"
click node_tileset "https://github.com/austridg/rad-2d/blob/master/tiles/tiles.cpp"
click node_tilemap "https://github.com/austridg/rad-2d/blob/master/tiles/tiles.cpp"

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_registries toneBlue
class node_animdef,node_animregistry,node_animstate toneAmber
class node_animated,node_sprite,node_background,node_text,node_ui toneMint
class node_tileset,node_tilemap toneRose
class node_game,node_raylib toneIndigo
```

## Components

### Asset management

- [Texture and font registries](https://github.com/austridg/rad-2d/blob/master/assets/assets.cpp): `assets/assets.cpp`

### Animation

- [Animation definitions](https://github.com/austridg/rad-2d/blob/master/animation/animation.cpp): `animation/animation.cpp`
- [Animation registry](https://github.com/austridg/rad-2d/blob/master/animation/animation.cpp): `animation/animation.cpp`
- [Animation state](https://github.com/austridg/rad-2d/blob/master/animation/animation.cpp): `animation/animation.cpp`

### Drawing

- [Animated drawable base](https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp): `draw/draw.cpp`
- [Sprite](https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp): `draw/draw.cpp`
- [Background](https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp): `draw/draw.cpp`
- [Text](https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp): `draw/draw.cpp`
- [UI element](https://github.com/austridg/rad-2d/blob/master/draw/draw.cpp): `draw/draw.cpp`

### Tilemaps

- [Tile set](https://github.com/austridg/rad-2d/blob/master/tiles/tiles.cpp): `tiles/tiles.cpp`
- [Tilemap](https://github.com/austridg/rad-2d/blob/master/tiles/tiles.cpp): `tiles/tiles.cpp`

### Other components

- **Game application**
- **raylib**

## Connections

- Game application → Texture and font registries: loads assets (evidence: `README.md`)
- Game application → Animation definitions: defines animations (evidence: `README.md`)
- Animation definitions → Animation registry: registers (evidence: `README.md`)
- Game application → Sprite: configures and draws (evidence: `README.md`)
- Game application → Background: draws (evidence: `README.md`)
- Game application → Text: draws (evidence: `README.md`)
- Game application → UI element: draws (evidence: `README.md`)
- Game application → Tilemap: draws (evidence: `README.md`)
- Animated drawable base → Animation registry: fetches animation (evidence: `draw/draw.cpp`)
- Animated drawable base → Animation state: sets playback (evidence: `draw/draw.cpp`)
- Sprite → Animated drawable base: inherits (evidence: `draw/draw.cpp`)
- Background → Animated drawable base: inherits (evidence: `draw/draw.cpp`)
- UI element → Animated drawable base: inherits (evidence: `draw/draw.cpp`)
- UI element → Text: draws attached text (evidence: `draw/draw.cpp`)
- Tile set → Animation registry: fetches animation (evidence: `tiles/tiles.cpp`)
- Tile set → Animation state: advances animated tiles (evidence: `tiles/tiles.cpp`)
- Tilemap → Tile set: looks up tiles (evidence: `tiles/tiles.cpp`)
- Texture and font registries → raylib: manages assets
- Sprite → raylib: renders
- Background → raylib: renders (evidence: `draw/draw.cpp`)
- Text → raylib: renders glyphs (evidence: `draw/draw.cpp`)
- UI element → raylib: renders (evidence: `draw/draw.cpp`)
- Tilemap → raylib: renders tiles (evidence: `tiles/tiles.cpp`)
