# jamesmcmahon/monocle-engine architecture

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

- Interactive diagram: https://gitdiagram.com/jamesmcmahon/monocle-engine
- Repository: https://github.com/jamesmcmahon/monocle-engine

## Overview

Monocle is a 2D game runtime framework. Its central workflow is the engine updating input and the current scene; the scene manages entities and their components, while renderers draw visible content and entities use colliders for spatial queries. Supporting branches provide virtual input, graphics and textures, particles, timing/state logic, and developer commands. Relationships reflect the excerpts and SOURCE INDEX references; unsampled subsystems are included where the tree identifies them, but their internal wiring is not asserted.

Main entry points: [`Monocle/Engine.cs`](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Engine.cs) (Engine loop), [`Monocle/Scene.cs`](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Scene.cs) (Scene manager), [`Monocle/Entity.cs`](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Entity.cs) (Entity), [`Monocle/Components/Component.cs`](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/Component.cs) (Component lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and Scenes"]
  node_engine["Engine loop<br/>[Engine.cs]"]
  node_scene["Scene manager<br/>[Scene.cs]"]
  node_entitylist["Entity lists<br/>[EntityList.cs]"]
end

subgraph group_spatial["Entities and Collision"]
  node_entity["Entity<br/>[Entity.cs]"]
  node_component["Component lifecycle<br/>[Component.cs]"]
  node_tracker["Object tracker<br/>[Tracker.cs]"]
  node_collidable["Collidable component"]
  node_collider["Collider shapes<br/>[Collider.cs]"]
  node_collision["Collision queries<br/>[Collide.cs]"]
  node_hitbox["Hitbox collider<br/>[Hitbox.cs]"]
  node_grid["Grid collider<br/>[Grid.cs]"]
  node_circle["Circle collider<br/>[Circle.cs]"]
end

subgraph group_graphics["Graphics and Rendering"]
  node_renderer["Renderer base<br/>[Renderer.cs]"]
  node_tagrenderers["Tag renderers"]
  node_camera["Camera<br/>[Camera.cs]"]
  node_draw["Drawing primitives<br/>[Draw.cs]"]
  node_texture["Texture regions<br/>[MTexture.cs]"]
  node_atlas["Texture atlas<br/>[Atlas.cs]"]
  node_sprite["Sprite component<br/>[Sprite.cs]"]
  node_particles["Particle system<br/>[ParticleSystem.cs]"]
  node_text["Text graphics<br/>[Text.cs]"]
end

subgraph group_support["Input and Utilities"]
  node_input["Input polling<br/>[MInput.cs]"]
  node_virtualinput["Virtual controls<br/>[VirtualInput.cs]"]
  node_commands["Command console<br/>[Commands.cs]"]
  node_calc["Math utilities<br/>[Calc.cs]"]
  node_logic["Logic components"]
end

node_game(("Game host"))

node_game -.->|"starts"| node_engine
node_engine -->|"initializes"| node_input
node_engine -->|"creates"| node_commands
node_engine -->|"updates"| node_scene
node_engine -->|"initializes"| node_draw
node_scene -->|"manages"| node_entitylist
node_scene -->|"creates"| node_tracker
node_scene -->|"manages"| node_renderer
node_tagrenderers -->|"extends"| node_renderer
node_entitylist -->|"manages"| node_entity
node_entity -->|"owns"| node_component
node_entity -->|"uses"| node_collider
node_component -->|"registers with"| node_tracker
node_collidable -->|"extends"| node_component
node_collidable -->|"uses"| node_collider
node_collider -->|"dispatches to"| node_collision
node_circle -->|"queries"| node_collision
node_circle -->|"dispatches to"| node_hitbox
node_circle -->|"dispatches to"| node_grid
node_collision -->|"uses"| node_calc
node_input -->|"updates"| node_virtualinput
node_commands -->|"reads"| node_input
node_sprite -->|"loads from"| node_atlas
node_sprite -->|"draws with"| node_texture
node_atlas -->|"creates"| node_texture
node_texture -->|"draws through"| node_draw
node_text -->|"renders through"| node_draw
node_particles -->|"extends"| node_entity
node_particles -->|"uses"| node_calc
node_camera -->|"reads"| node_engine
node_logic -.->|"extends"| node_component

click node_engine "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Engine.cs"
click node_scene "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Scene.cs"
click node_entitylist "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/InternalUtilities/EntityList.cs"
click node_renderer "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Renderers/Renderer.cs"
click node_tagrenderers "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Renderers/SingleTagRenderer.cs"
click node_entity "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Entity.cs"
click node_component "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/Component.cs"
click node_tracker "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Tracker.cs"
click node_collidable "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/CollidableComponent.cs"
click node_collider "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Collider.cs"
click node_collision "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Collide.cs"
click node_hitbox "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Hitbox.cs"
click node_grid "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Grid.cs"
click node_circle "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Circle.cs"
click node_input "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Input/MInput.cs"
click node_virtualinput "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Input/VirtualInput.cs"
click node_commands "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Commands.cs"
click node_calc "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Calc.cs"
click node_camera "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Camera.cs"
click node_draw "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Draw.cs"
click node_texture "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Graphics/MTexture.cs"
click node_atlas "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Graphics/Atlas.cs"
click node_sprite "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/Graphics/Sprite.cs"
click node_particles "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Particles/ParticleSystem.cs"
click node_logic "https://github.com/jamesmcmahon/monocle-engine/tree/master/Monocle/Components/Logic"
click node_text "https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/Graphics/Text/Text.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_engine,node_scene,node_entitylist toneBlue
class node_entity,node_component,node_tracker,node_collidable,node_collider,node_collision,node_hitbox,node_grid,node_circle toneAmber
class node_renderer,node_tagrenderers,node_camera,node_draw,node_texture,node_atlas,node_sprite,node_particles,node_text toneMint
class node_input,node_virtualinput,node_commands,node_calc,node_logic toneRose
class node_game toneIndigo
```

## Components

### Runtime and Scenes

- [Engine loop](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Engine.cs): `Monocle/Engine.cs`
- [Scene manager](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Scene.cs): `Monocle/Scene.cs`
- [Entity lists](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/InternalUtilities/EntityList.cs): `Monocle/InternalUtilities/EntityList.cs`

### Entities and Collision

- [Entity](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Entity.cs): `Monocle/Entity.cs`
- [Component lifecycle](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/Component.cs): `Monocle/Components/Component.cs`
- [Object tracker](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Tracker.cs): `Monocle/Util/Tracker.cs`
- [Collidable component](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/CollidableComponent.cs): `Monocle/Components/CollidableComponent.cs`
- [Collider shapes](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Collider.cs): `Monocle/Colliders/Collider.cs`
- [Collision queries](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Collide.cs): `Monocle/Colliders/Collide.cs`
- [Hitbox collider](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Hitbox.cs): `Monocle/Colliders/Hitbox.cs`
- [Grid collider](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Grid.cs): `Monocle/Colliders/Grid.cs`
- [Circle collider](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Colliders/Circle.cs): `Monocle/Colliders/Circle.cs`

### Graphics and Rendering

- [Renderer base](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Renderers/Renderer.cs): `Monocle/Renderers/Renderer.cs`
- [Tag renderers](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Renderers/SingleTagRenderer.cs): `Monocle/Renderers/SingleTagRenderer.cs`
- [Camera](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Camera.cs): `Monocle/Util/Camera.cs`
- [Drawing primitives](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Draw.cs): `Monocle/Util/Draw.cs`
- [Texture regions](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Graphics/MTexture.cs): `Monocle/Graphics/MTexture.cs`
- [Texture atlas](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Graphics/Atlas.cs): `Monocle/Graphics/Atlas.cs`
- [Sprite component](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/Graphics/Sprite.cs): `Monocle/Components/Graphics/Sprite.cs`
- [Particle system](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Particles/ParticleSystem.cs): `Monocle/Particles/ParticleSystem.cs`
- [Text graphics](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Components/Graphics/Text/Text.cs): `Monocle/Components/Graphics/Text/Text.cs`

### Input and Utilities

- [Input polling](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Input/MInput.cs): `Monocle/Input/MInput.cs`
- [Virtual controls](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Input/VirtualInput.cs): `Monocle/Input/VirtualInput.cs`
- [Command console](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Commands.cs): `Monocle/Util/Commands.cs`
- [Math utilities](https://github.com/jamesmcmahon/monocle-engine/blob/master/Monocle/Util/Calc.cs): `Monocle/Util/Calc.cs`
- [Logic components](https://github.com/jamesmcmahon/monocle-engine/tree/master/Monocle/Components/Logic): `Monocle/Components/Logic`

### Other components

- **Game host**

## Connections

- Game host → Engine loop: starts
- Engine loop → Input polling: initializes (evidence: `Monocle/Engine.cs`)
- Engine loop → Command console: creates (evidence: `Monocle/Engine.cs`)
- Engine loop → Scene manager: updates (evidence: `Monocle/Engine.cs`)
- Engine loop → Drawing primitives: initializes (evidence: `Monocle/Engine.cs`)
- Scene manager → Entity lists: manages (evidence: `Monocle/Scene.cs`)
- Scene manager → Object tracker: creates (evidence: `Monocle/Scene.cs`)
- Scene manager → Renderer base: manages (evidence: `Monocle/Scene.cs`)
- Tag renderers → Renderer base: extends (evidence: `Monocle/Renderers/SingleTagRenderer.cs`)
- Entity lists → Entity: manages (evidence: `Monocle/InternalUtilities/EntityList.cs`)
- Entity → Component lifecycle: owns (evidence: `Monocle/Entity.cs`)
- Entity → Collider shapes: uses (evidence: `Monocle/Entity.cs`)
- Component lifecycle → Object tracker: registers with (evidence: `Monocle/Components/Component.cs`)
- Collidable component → Component lifecycle: extends (evidence: `Monocle/Components/CollidableComponent.cs`)
- Collidable component → Collider shapes: uses (evidence: `Monocle/Components/CollidableComponent.cs`)
- Collider shapes → Collision queries: dispatches to (evidence: `Monocle/Colliders/Collider.cs`)
- Circle collider → Collision queries: queries (evidence: `Monocle/Colliders/Circle.cs`)
- Circle collider → Hitbox collider: dispatches to (evidence: `Monocle/Colliders/Circle.cs`)
- Circle collider → Grid collider: dispatches to (evidence: `Monocle/Colliders/Circle.cs`)
- Collision queries → Math utilities: uses (evidence: `Monocle/Colliders/Collide.cs`)
- Input polling → Virtual controls: updates (evidence: `Monocle/Input/MInput.cs`)
- Command console → Input polling: reads (evidence: `Monocle/Util/Commands.cs`)
- Sprite component → Texture atlas: loads from (evidence: `Monocle/Components/Graphics/Sprite.cs`)
- Sprite component → Texture regions: draws with (evidence: `Monocle/Components/Graphics/Sprite.cs`)
- Texture atlas → Texture regions: creates (evidence: `Monocle/Graphics/Atlas.cs`)
- Texture regions → Drawing primitives: draws through (evidence: `Monocle/Graphics/MTexture.cs`)
- Text graphics → Drawing primitives: renders through (evidence: `Monocle/Components/Graphics/Text/Text.cs`)
- Particle system → Entity: extends (evidence: `Monocle/Particles/ParticleSystem.cs`)
- Particle system → Math utilities: uses (evidence: `Monocle/Particles/ParticleSystem.cs`)
- Camera → Engine loop: reads (evidence: `Monocle/Util/Camera.cs`)
- Logic components → Component lifecycle: extends (evidence: `Monocle/Components/Logic/Tween.cs`)
