# salman-3107/game architecture

> Architecture diagram of the GitHub repository salman-3107/game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/salman-3107/game
- Repository: https://github.com/salman-3107/game

## Overview

##### Project type and purpose
- This is a small, single‐player desktop game written in C++.
- It uses a custom “iGraphics” library (wrapping OpenGL/SDL calls) for rendering and input, plus a simple sound interface (iSound).
- Purpose: implement a classic “Bounce” arcade game with levels, obstacles, scoring and sound.

##### File structure
Top-level of interest (ignore the huge MINGW/OpenGL SDK folders—they are external toolchains):
- bounce_classic.cpp – main game implementation (game loop, logic, menu, levels)
- iGraphics.h / iSound.h / iFont.h – interfaces to graphics, sound, font subsystems
- assets/ – images (BMPs) and sounds (WAV), organized by function (menus, levels)
- obj/ – compiled object files (e.g., opengl.o)
- bin / release / runner scripts (.bat, .sh) – packaging, launching, build helpers
- highscore.txt, saves/names.txt – persistent storage for leaderboards

##### README for insights
- Confirms C++ + iGraphics library (which under the hood uses OpenGL/SDL).
- Describes game features: menu, levels, physics, scoring.

##### Components
a. Main components
- Game Client (desktop executable)
- Asset Manager (images, sounds, fonts loader)
- Graphics Subsystem (iGraphics → SDL/OpenGL)
- Audio Subsystem (iSound → SDL_mixer or WAV playback)
- Input Handler (keyboard/mouse events via SDL)
- Game Logic / Physics Engine (ball movement, collisions, level progression)
- Persistence Layer (reads/writes highscore.txt, names.txt)
- Build Toolchain (GCC via MinGW)

b. Relationships & data flow
1. At build time:
Source files (bounce_classic.cpp + headers)
→ compiled by GCC (MinGW)
→ linked with iGraphics, OpenGL, SDL libs
→ produces Game Client binary
2. At runtime:
Game Client
→ calls Asset Manager to load bitmaps/WAVs
→ Input Handler polls SDL events → passes to Game Logic
→ Graphics Subsystem renders frames
→ Audio Subsystem plays sound effects/music
→ On leaderboard update, Persistence Layer writes files

c. Architectural patterns / principles
- Monolithic C++ application with clear separation of subsystems (graphics, audio, input, logic).
- Event‐loop architecture (single thread processing input → update → render → sound).
- Asset Manager as a resource cache.
- Simple file‐based persistence (text files for highscores).

d. Key technologies
- C++
- iGraphics library (wrapper over SDL + OpenGL)
- SDL2 / OpenGL (for rendering & event/input)
- MinGW GCC toolchain (build)
- WAV sound playback (via iSound)
- BMP image format

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build Toolchain
    subgraph "Build Toolchain"
        Source["Source Code (.cpp/.h)"]:::code
        GCC["GCC (MinGW)"]:::build
        Obj["obj/opengl.o"]:::code
        Binaries["bin/"]:::code
        Scripts["release.bat / copy.bat / runner scripts"]:::build

        Source -->|compile| GCC
        GCC -->|produce object| Obj
        Obj -->|link| GCC
        GCC -->|produce executable| Binaries
        Scripts -->|invoke build| GCC
    end

    %% Game Client
    subgraph "Bounce Classic Game Client"
        AM["Asset Manager"]:::code
        IH["Input Handler"]:::code
        GL["Game Logic / Physics Engine"]:::code
        GS["Graphics Subsystem"]:::extlib
        AS["Audio Subsystem"]:::extlib
        PL["Persistence Layer"]:::code
        FS["Font Subsystem"]:::extlib

        AM -->|"load images"| GS
        AM -->|"load sounds"| AS
        IH -->|"events"| GL
        GL -->|"render commands"| GS
        GL -->|"sound commands"| AS
        GL -->|"write scores"| PL
    end

    %% Resources
    AssetsImg["assets/images/*.bmp"]:::resource
    AssetsSnd["assets/sounds/*.wav"]:::resource
    AssetsFnt["assets/fonts/*"]:::resource
    Highscore["highscore.txt"]:::resource
    Names["saves/names.txt"]:::resource

    AssetsImg -->|load| AM
    AssetsSnd -->|load| AM
    AssetsFnt -->|load| AM
    Highscore -->|read/write| PL
    Names -->|read/write| PL

    %% External Libraries
    IG["iGraphics.h"]:::extlib
    IS["iSound.h"]:::extlib
    IF["iFont.h"]:::extlib
    SDL2Hdrs["OpenGL/include/SDL2/"]:::extlib
    GLHdrs["OpenGL/include/GL/"]:::extlib
    SDLLibs["OpenGL/lib/"]:::extlib

    IG --> GS
    SDL2Hdrs --> GS
    GLHdrs --> GS
    SDLLibs --> GS
    IS --> AS
    SDL2Hdrs --> AS
    SDLLibs --> AS
    IF --> FS
    SDL2Hdrs --> IH

    %% Click Events
    click Source "https://github.com/salman-3107/game/blob/main/bounce_classic.cpp"
    click Obj "https://github.com/salman-3107/game/blob/main/obj/opengl.o"
    click Binaries "https://github.com/salman-3107/game/tree/main/bin/"
    click Scripts "https://github.com/salman-3107/game/blob/main/release.bat"
    click AssetsImg "https://github.com/salman-3107/game/tree/main/assets/images/"
    click AssetsSnd "https://github.com/salman-3107/game/tree/main/assets/sounds/"
    click AssetsFnt "https://github.com/salman-3107/game/tree/main/assets/fonts/"
    click IG "https://github.com/salman-3107/game/blob/main/iGraphics.h"
    click IS "https://github.com/salman-3107/game/blob/main/iSound.h"
    click IF "https://github.com/salman-3107/game/blob/main/iFont.h"
    click SDL2Hdrs "https://github.com/salman-3107/game/tree/main/OpenGL/include/SDL2/"
    click GLHdrs "https://github.com/salman-3107/game/tree/main/OpenGL/include/GL/"
    click SDLLibs "https://github.com/salman-3107/game/tree/main/OpenGL/lib/"

    %% Styles
    classDef code fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef extlib fill:#98FB98,stroke:#000,stroke-width:1px
    classDef resource fill:#FFA500,stroke:#000,stroke-width:1px
    classDef build fill:#D3D3D3,stroke:#000,stroke-width:1px
```
