# magomestrexd/trabalhocg2d architecture

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

- Interactive diagram: https://gitdiagram.com/magomestrexd/trabalhocg2d
- Repository: https://github.com/magomestrexd/trabalhocg2d

## Overview

This repository is a C++/SDL 2D game. The visible gameplay loop is driven by Game: it updates the player and game state, manages entities and projectiles, checks collisions, and draws the scene. Rendering runs through the rasterizer and sprite manager. The README provides no product detail, so gameplay capabilities are based on the sampled Game interface; unsampled implementation links are omitted where they cannot be verified.

Main entry points: [`src/spriteManager.cpp`](https://github.com/magomestrexd/trabalhocg2d/blob/main/src/spriteManager.cpp) (Sprite manager), [`include/game.h`](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/game.h) (Game controller), [`src/rasterizer.cpp`](https://github.com/magomestrexd/trabalhocg2d/blob/main/src/rasterizer.cpp) (Rasterizer), [`include/player.h`](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/player.h) (Player)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_game["Game controller<br/>[game.h]"]
  node_entry["Application entry<br/>[main.cpp]"]
end

subgraph group_gameplay["Gameplay"]
  node_player["Player<br/>[player.h]"]
  node_entities["Entities<br/>[entity.h]"]
  node_upgrades["Timed upgrades<br/>[upgrade.h]"]
end

subgraph group_rendering["Rendering"]
  node_minimap["Minimap<br/>[viewport.h]"]
  node_rasterizer["Rasterizer<br/>[rasterizer.cpp]"]
  node_sprite_manager["Sprite manager<br/>[spriteManager.cpp]"]
  node_sprite["Sprite rotation<br/>[sprite.h]"]
end

subgraph group_model["Game model"]
  node_room["Room bounds<br/>[room.h]"]
  node_texture["Texture pixels<br/>[texture.h]"]
  node_geometry["Polygon geometry<br/>[polygon.h]"]
  node_sprite_key["Sprite keys<br/>[spriteKey.h]"]
  node_sprite_types["Sprite types<br/>[spriteType.h]"]
  node_assets["Image assets"]
end

node_sdl["SDL runtime"]

node_entry -->|"starts"| node_game
node_game -->|"updates and draws"| node_player
node_game -->|"manages and draws"| node_entities
node_game -->|"updates and draws"| node_upgrades
node_game -->|"draws positions"| node_minimap
node_game -->|"sets bounds"| node_room
node_player -->|"inherits"| node_entities
node_player -->|"requests sprites"| node_sprite_manager
node_player -->|"draws sprites"| node_rasterizer
node_entities -->|"requests sprites"| node_sprite_manager
node_entities -->|"draws geometry"| node_rasterizer
node_sprite_manager -->|"rasterizes textures"| node_rasterizer
node_sprite_manager -->|"stores sprites"| node_sprite
node_sprite_manager -->|"loads pixels"| node_texture
node_sprite_manager -->|"keys sprites"| node_sprite_key
node_sprite_manager -->|"selects images"| node_sprite_types
node_sprite_manager -->|"loads images"| node_assets
node_sprite_manager -->|"loads surfaces"| node_sdl
node_sprite -->|"rotates pixels"| node_texture
node_rasterizer -->|"rasterizes polygons"| node_geometry
node_rasterizer -->|"draws pixels"| node_texture
node_rasterizer -.->|"renders frames"| node_sdl

click node_player "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/player.h"
click node_game "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/game.h"
click node_entry "https://github.com/magomestrexd/trabalhocg2d/blob/main/src/main.cpp"
click node_entities "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/entity.h"
click node_upgrades "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/upgrade.h"
click node_room "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/room.h"
click node_minimap "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/viewport.h"
click node_rasterizer "https://github.com/magomestrexd/trabalhocg2d/blob/main/src/rasterizer.cpp"
click node_sprite_manager "https://github.com/magomestrexd/trabalhocg2d/blob/main/src/spriteManager.cpp"
click node_sprite "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/sprite.h"
click node_texture "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/texture.h"
click node_geometry "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/polygon.h"
click node_sprite_key "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/spriteKey.h"
click node_sprite_types "https://github.com/magomestrexd/trabalhocg2d/blob/main/include/spriteType.h"
click node_assets "https://github.com/magomestrexd/trabalhocg2d/tree/main/resources"

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_entry toneBlue
class node_player,node_entities,node_upgrades toneAmber
class node_minimap,node_rasterizer,node_sprite_manager,node_sprite toneMint
class node_room,node_texture,node_geometry,node_sprite_key,node_sprite_types,node_assets toneRose
class node_sdl toneIndigo
```

## Components

### Game runtime

- [Game controller](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/game.h): `include/game.h`
- [Application entry](https://github.com/magomestrexd/trabalhocg2d/blob/main/src/main.cpp): `src/main.cpp`

### Gameplay

- [Player](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/player.h): `include/player.h`
- [Entities](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/entity.h): `include/entity.h`
- [Timed upgrades](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/upgrade.h): `include/upgrade.h`

### Rendering

- [Minimap](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/viewport.h): `include/viewport.h`
- [Rasterizer](https://github.com/magomestrexd/trabalhocg2d/blob/main/src/rasterizer.cpp): `src/rasterizer.cpp`
- [Sprite manager](https://github.com/magomestrexd/trabalhocg2d/blob/main/src/spriteManager.cpp): `src/spriteManager.cpp`
- [Sprite rotation](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/sprite.h): `include/sprite.h`

### Game model

- [Room bounds](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/room.h): `include/room.h`
- [Texture pixels](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/texture.h): `include/texture.h`
- [Polygon geometry](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/polygon.h): `include/polygon.h`
- [Sprite keys](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/spriteKey.h): `include/spriteKey.h`
- [Sprite types](https://github.com/magomestrexd/trabalhocg2d/blob/main/include/spriteType.h): `include/spriteType.h`
- [Image assets](https://github.com/magomestrexd/trabalhocg2d/tree/main/resources): `resources`

### Other components

- **SDL runtime**

## Connections

- Application entry → Game controller: starts (evidence: `src/main.cpp`)
- Game controller → Player: updates and draws (evidence: `include/game.h`)
- Game controller → Entities: manages and draws (evidence: `include/game.h`)
- Game controller → Timed upgrades: updates and draws (evidence: `include/game.h`)
- Game controller → Minimap: draws positions (evidence: `include/game.h`)
- Game controller → Room bounds: sets bounds (evidence: `include/game.h`)
- Player → Entities: inherits (evidence: `include/player.h`)
- Player → Sprite manager: requests sprites (evidence: `include/player.h`)
- Player → Rasterizer: draws sprites (evidence: `include/player.h`)
- Entities → Sprite manager: requests sprites (evidence: `include/entity.h`)
- Entities → Rasterizer: draws geometry (evidence: `include/entity.h`)
- Sprite manager → Rasterizer: rasterizes textures (evidence: `src/spriteManager.cpp`)
- Sprite manager → Sprite rotation: stores sprites
- Sprite manager → Texture pixels: loads pixels (evidence: `src/spriteManager.cpp`)
- Sprite manager → Sprite keys: keys sprites (evidence: `src/spriteManager.cpp`)
- Sprite manager → Sprite types: selects images (evidence: `src/spriteManager.cpp`)
- Sprite manager → Image assets: loads images (evidence: `src/spriteManager.cpp`)
- Sprite manager → SDL runtime: loads surfaces (evidence: `src/spriteManager.cpp`)
- Sprite rotation → Texture pixels: rotates pixels (evidence: `include/sprite.h`)
- Rasterizer → Polygon geometry: rasterizes polygons
- Rasterizer → Texture pixels: draws pixels
- Rasterizer → SDL runtime: renders frames
