# uzairexy/sfml_c-_simple_games architecture

> Architecture diagram of the GitHub repository uzairexy/sfml_c-_simple_games, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uzairexy/sfml_c-_simple_games
- Repository: https://github.com/uzairexy/sfml_c-_simple_games

## Overview

##### Project type and purpose
- This is a desktop C++ monolithic application that bundles several simple 2D games built on top of the SFML multimedia library.
- Each “Game” (Game 1, Game 2, Game 3) lives in its own subfolder under SFML_C++_Simple_Games/SFML_C++_Simple_Games but reuses common engine components (Game base class, Entity classes, Tile/TileMap).

##### File structure
- Top-level SFML_C++_Simple_Games folder:
- .vs (Visual Studio solution metadata)
- Release (compiled .exe, .pdb, .ipdb for shipping)
- SFML_C++_Simple_Games (actual source tree)
- Inside source tree:
- Fonts/Textures (static assets)
- Game 1, Game 2, Game 3 (per-game entry points and overrides)
- Core classes: Game.cpp/.h, Player.cpp/.h, Tile.cpp/.h, TileMap.cpp/.h, etc.
- stdafx.* (precompiled header support)
- main.cpp (application entry, chooses/runs a Game)

##### README
- Confirms “Simple games made in C++ and SFML.”
- No higher-level architecture docs, so we infer a shared engine + per-game specialization design.

a. Main components
- Application (main.cpp)
- Core Engine Subsystem
– Game Loop Manager
– Input Handler
– Renderer
– Resource Manager (loads from Fonts/Textures)
- Game Modules
– Game1, Game2, Game3 (inherit from Game base class)
- Domain Entities
– Player, Enemy, Bullet, SwagBall
- System
– Tile, TileMap
- External Dependency
– SFML Library (Graphics, Window, Audio, System)

b. Relationships & interactions
- Application → initializes SFML::RenderWindow
- Application → instantiates chosen Game module
- Entities and Map System interact during update/render phases

c. Architectural patterns / design principles
- Monolithic modular structure: a shared “engine” with plug-in style Game subclasses
- Base class polymorphism: Game interface, overridden by each Game N
- Resource centralization: Resource Manager loads and caches fonts/textures

d. Key technologies / frameworks
- C++17 (or C++14)
- SFML (Graphics, Window, System, Audio modules)
- Visual Studio solution (precompiled headers, Debug/Release folders)

##### Capturing essential elements
- You include deployment artifacts (Release folder with .exe) off to one side
- Build-time PCH optimization (stdafx) as a footnote

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Application
    App["Application\n(main.cpp)"]:::engine

    subgraph "C++ Monolithic App"
        direction TB

        %% Core Engine
        subgraph "Core Engine"
            direction TB
            GameBase["Game Base Class\n(Game.h/.cpp)"]:::engine
            GameLoop["Game Loop Manager"]:::engine
            InputHandler["Input Handler"]:::engine
            Renderer["Renderer"]:::engine
            ResourceMgr["Resource Manager\n(Fonts/Textures)"]:::resources
            Precompiled["PCH Support\n(stdafx.h/.cpp)"]:::engine
        end

        %% Map System
        subgraph "Map System"
            direction TB
            Tile["Tile\n(Tile.h/.cpp)"]:::entities
            TileMap["TileMap\n(TileMap.h/.cpp)"]:::entities
        end

        %% Domain Entities
        subgraph "Domain Entities"
            direction TB
            Player["Player\n(Player.h/.cpp)"]:::entities
        end

        %% Game Modules
        subgraph "Game Modules"
            direction TB
            Game1["Game 1 Module"]:::modules
            Game2["Game 2 Module"]:::modules
            Game3["Game 3 Module"]:::modules
        end
    end

    %% External and Deployment
    SFML["SFML Library\n(Graphics, Window, Audio)"]:::external
    Release["Release Artifacts\n(.exe, .pdb)"]:::external

    %% Relationships
    App -->|"initializes"| SFML
    App -->|"instantiates"| GameBase
    App --> Game1
    App --> Game2
    App --> Game3

    Game1 -->|inherits| GameBase
    Game2 -->|inherits| GameBase
    Game3 -->|inherits| GameBase

    GameBase --> GameLoop
    GameLoop -->|"polls"| InputHandler
    InputHandler -->|"events to"| Player
    GameLoop -->|"updates"| Player
    GameLoop -->|"updates"| TileMap
    ResourceMgr -->|"loads assets for"| Renderer
    GameLoop -->|"renders via"| Renderer
    Renderer -->|"draw calls to"| SFML

    %% Click Events
    click App "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/main.cpp"
    click GameBase "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Game.h"
    click GameBase "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Game.cpp"
    click ResourceMgr "https://github.com/uzairexy/sfml_c-_simple_games/tree/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Fonts"
    click ResourceMgr "https://github.com/uzairexy/sfml_c-_simple_games/tree/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Textures"
    click Tile "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Tile.h"
    click Tile "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Tile.cpp"
    click TileMap "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/TileMap.h"
    click TileMap "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/TileMap.cpp"
    click Precompiled "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/stdafx.h"
    click Precompiled "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/stdafx.cpp"
    click Player "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Player.h"
    click Player "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Player.cpp"
    click Game1 "https://github.com/uzairexy/sfml_c-_simple_games/tree/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Game 1"
    click Game2 "https://github.com/uzairexy/sfml_c-_simple_games/tree/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Game 2"
    click Game3 "https://github.com/uzairexy/sfml_c-_simple_games/tree/master/SFML_C++_Simple_Games/SFML_C++_Simple_Games/Game 3"
    click Release "https://github.com/uzairexy/sfml_c-_simple_games/blob/master/SFML_C++_Simple_Games/Release/SFML_C++_Simple_Games.exe"

    %% Styles
    classDef engine fill:#D0E1F9,stroke:#333,stroke-width:1px
    classDef modules fill:#A8D5BA,stroke:#333,stroke-width:1px
    classDef resources fill:#DFF9D0,stroke:#333,stroke-width:1px
    classDef entities fill:#F1E0C5,stroke:#333,stroke-width:1px
    classDef external fill:#F9D0D0,stroke:#333,stroke-width:1px
```
