# rdappel/katanaengine architecture

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

- Interactive diagram: https://gitdiagram.com/rdappel/katanaengine
- Repository: https://github.com/rdappel/katanaengine

## Overview

KatanaEngine is a lightweight C++ 2D game engine. A game implementation enters through Game, whose runtime provides timing, input, resource access, rendering, and optional screen-stack management; screens handle scene-specific input, updates, and drawing. Supporting branches provide asset loading, UI controls, particles, math, persistence, platform integration, and hosted-game interop. The README documents the capabilities and usage flow; source excerpts show resource caching and screen dispatch. Some subsystem internals were not sampled, so their connections are omitted where evidence is insufficient.

Main entry points: [`Source/Core/Game.cpp`](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Game.cpp) (Game Loop), [`Source/Core/Resource/ResourceManager.cpp`](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/ResourceManager.cpp) (Resource Cache), [`Source/Core/Screens/Screen.h`](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Screens/Screen.h) (Game Screen), [`Source/Core/Graphics/SpriteBatch.cpp`](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Graphics/SpriteBatch.cpp) (Sprite Rendering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_game["Game Loop<br/>[Game.cpp]"]
  node_time["Frame Timing<br/>[GameTime.h]"]
  node_input["Input State<br/>[InputState.cpp]"]
  node_screens["Screen Stack<br/>[ScreenManager.cpp]"]
  node_screen["Game Screen<br/>[Screen.h]"]
end

subgraph group_visuals["Graphics and Assets"]
  node_render["Sprite Rendering<br/>[SpriteBatch.cpp]"]
  node_camera["Camera<br/>[Camera.cpp]"]
  node_resources["Resource Cache"]
  node_texture["Texture Assets<br/>[Texture.cpp]"]
  node_animation["Animations<br/>[AnimationSet.cpp]"]
  node_effects["Effects<br/>[Effect.cpp]"]
  node_audio["Audio Assets<br/>[Music.cpp]"]
  node_curve["Animation Curves<br/>[Curve.cpp]"]
end

subgraph group_interaction["Game Interaction"]
  node_gui["UI Controls<br/>[Control.cpp]"]
  node_particles["Particle System<br/>[ParticleEmitter.h]"]
  node_math["Math Geometry<br/>[Vector2.h]"]
end

subgraph group_services["Platform Services"]
  node_save["Save Management<br/>[SaveManager.cpp]"]
  node_platform["Allegro Platform<br/>[Platform.h]"]
  node_services["Engine Services<br/>[EngineServices.h]"]
end

subgraph group_interop["Hosting Integration"]
  node_host["Native Game Host<br/>[GameHost.cpp]"]
  node_viewport["WinForms Viewport<br/>[KatanaViewport.cs]"]
  node_native["Native Library Bridge"]
end

node_player(("Game Project"))

node_player -->|"runs"| node_game
node_game -->|"polls"| node_input
node_game -->|"tracks"| node_time
node_game -->|"draws with"| node_render
node_game -->|"manages"| node_screens
node_screens -->|"dispatches"| node_screen
node_game -->|"provides"| node_resources
node_resources -->|"loads"| node_texture
node_resources -->|"loads"| node_animation
node_resources -->|"loads"| node_effects
node_resources -->|"loads"| node_audio
node_resources -->|"loads"| node_curve
node_render -->|"supports"| node_camera
node_render -->|"draws"| node_texture
node_screen -->|"loads content"| node_resources
node_screen -->|"handles input"| node_input
node_screen -->|"draws with"| node_render
node_player -->|"uses"| node_gui
node_player -->|"uses"| node_particles
node_game -->|"runs on"| node_platform
node_game -->|"configures"| node_services
node_player -.->|"persists state"| node_save
node_game -.->|"supports hosting"| node_host
node_viewport -->|"calls"| node_native
node_native -.->|"bridges to"| node_host

click node_game "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Game.cpp"
click node_time "https://github.com/rdappel/katanaengine/blob/master/Source/Core/GameTime.h"
click node_input "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Input/InputState.cpp"
click node_screens "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Screens/ScreenManager.cpp"
click node_screen "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Screens/Screen.h"
click node_render "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Graphics/SpriteBatch.cpp"
click node_camera "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Camera.cpp"
click node_resources "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/ResourceManager.cpp"
click node_texture "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/Texture.cpp"
click node_animation "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/AnimationSet.cpp"
click node_effects "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/Effect.cpp"
click node_audio "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/Music.cpp"
click node_curve "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Math/Curve.cpp"
click node_gui "https://github.com/rdappel/katanaengine/blob/master/Source/GUI/Control.cpp"
click node_particles "https://github.com/rdappel/katanaengine/blob/master/Source/Particles/ParticleEmitter.h"
click node_math "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Math/Vector2.h"
click node_save "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Save/SaveManager.cpp"
click node_platform "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Platform/Platform.h"
click node_services "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Services/EngineServices.h"
click node_host "https://github.com/rdappel/katanaengine/blob/master/Source/Core/Hosting/GameHost.cpp"
click node_viewport "https://github.com/rdappel/katanaengine/blob/master/WinForms/KatanaViewport.cs"
click node_native "https://github.com/rdappel/katanaengine/blob/master/WinForms/NativeGameLibrary.cs"

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_game,node_time,node_input,node_screens,node_screen toneBlue
class node_render,node_camera,node_resources,node_texture,node_animation,node_effects,node_audio,node_curve toneAmber
class node_gui,node_particles,node_math toneMint
class node_save,node_platform,node_services toneRose
class node_host,node_viewport,node_native,node_player toneIndigo
```

## Components

### Game Runtime

- [Game Loop](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Game.cpp): `Source/Core/Game.cpp`
- [Frame Timing](https://github.com/rdappel/katanaengine/blob/master/Source/Core/GameTime.h): `Source/Core/GameTime.h`
- [Input State](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Input/InputState.cpp): `Source/Core/Input/InputState.cpp`
- [Screen Stack](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Screens/ScreenManager.cpp): `Source/Core/Screens/ScreenManager.cpp`
- [Game Screen](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Screens/Screen.h): `Source/Core/Screens/Screen.h`

### Graphics and Assets

- [Sprite Rendering](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Graphics/SpriteBatch.cpp): `Source/Core/Graphics/SpriteBatch.cpp`
- [Camera](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Camera.cpp): `Source/Core/Camera.cpp`
- [Resource Cache](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/ResourceManager.cpp): `Source/Core/Resource/ResourceManager.cpp`
- [Texture Assets](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/Texture.cpp): `Source/Core/Resource/Texture.cpp`
- [Animations](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/AnimationSet.cpp): `Source/Core/Resource/AnimationSet.cpp`
- [Effects](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/Effect.cpp): `Source/Core/Resource/Effect.cpp`
- [Audio Assets](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Resource/Music.cpp): `Source/Core/Resource/Music.cpp`
- [Animation Curves](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Math/Curve.cpp): `Source/Core/Math/Curve.cpp`

### Game Interaction

- [UI Controls](https://github.com/rdappel/katanaengine/blob/master/Source/GUI/Control.cpp): `Source/GUI/Control.cpp`
- [Particle System](https://github.com/rdappel/katanaengine/blob/master/Source/Particles/ParticleEmitter.h): `Source/Particles/ParticleEmitter.h`
- [Math Geometry](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Math/Vector2.h): `Source/Core/Math/Vector2.h`

### Platform Services

- [Save Management](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Save/SaveManager.cpp): `Source/Core/Save/SaveManager.cpp`
- [Allegro Platform](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Platform/Platform.h): `Source/Core/Platform/Platform.h`
- [Engine Services](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Services/EngineServices.h): `Source/Core/Services/EngineServices.h`

### Hosting Integration

- [Native Game Host](https://github.com/rdappel/katanaengine/blob/master/Source/Core/Hosting/GameHost.cpp): `Source/Core/Hosting/GameHost.cpp`
- [WinForms Viewport](https://github.com/rdappel/katanaengine/blob/master/WinForms/KatanaViewport.cs): `WinForms/KatanaViewport.cs`
- [Native Library Bridge](https://github.com/rdappel/katanaengine/blob/master/WinForms/NativeGameLibrary.cs): `WinForms/NativeGameLibrary.cs`

### Other components

- **Game Project**

## Connections

- Game Project → Game Loop: runs
- Game Loop → Input State: polls
- Game Loop → Frame Timing: tracks (evidence: `Source/Core/Game.cpp`)
- Game Loop → Sprite Rendering: draws with
- Game Loop → Screen Stack: manages (evidence: `Source/Core/Game.cpp`)
- Screen Stack → Game Screen: dispatches (evidence: `Source/Core/Screens/ScreenManager.cpp`)
- Game Loop → Resource Cache: provides
- Resource Cache → Texture Assets: loads (evidence: `Source/Core/Resource/ResourceManager.cpp`)
- Resource Cache → Animations: loads (evidence: `Source/Core/Resource/ResourceManager.cpp`)
- Resource Cache → Effects: loads (evidence: `Source/Core/Resource/ResourceManager.cpp`)
- Resource Cache → Audio Assets: loads (evidence: `Source/Core/Resource/ResourceManager.cpp`)
- Resource Cache → Animation Curves: loads (evidence: `Source/Core/Resource/ResourceManager.cpp`)
- Sprite Rendering → Camera: supports
- Sprite Rendering → Texture Assets: draws
- Game Screen → Resource Cache: loads content
- Game Screen → Input State: handles input
- Game Screen → Sprite Rendering: draws with
- Game Project → UI Controls: uses
- Game Project → Particle System: uses
- Game Loop → Allegro Platform: runs on
- Game Loop → Engine Services: configures (evidence: `Source/Core/Game.cpp`)
- Game Project → Save Management: persists state
- Game Loop → Native Game Host: supports hosting
- WinForms Viewport → Native Library Bridge: calls (evidence: `WinForms/KatanaViewport.cs`)
- Native Library Bridge → Native Game Host: bridges to
