# phimie/cryprawl architecture

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

- Interactive diagram: https://gitdiagram.com/phimie/cryprawl
- Repository: https://github.com/phimie/cryprawl

## Overview

##### Project Type and Purpose
- Cryprawl is a desktop arcade-style game built on Pygame.
- It’s structured as a single-process application with modules for entities, game loop orchestration, asset management, and packaging.

##### Major Components to Model
a. Game Core
– Cryprawl.py (main entrypoint)
– settings.py (configuration loader)
– rpath.py (resource-path helper)
b. Entity Modules
– ship.py, bullet.py, enemy.py, bat.py, Batmage.py, button.py
– These define classes, behaviors, collision logic.
c. Asset Management
– assets/audio/… (effects, music, UI sounds)
– rpath.py helps locate these at runtime.
d. Input Handler
– Integrated in Cryprawl.py’s event loop (keyboard/mouse events → entity actions)
e. Renderer
– Pygame display subsystem invoked by Game Core
– Draws sprites, backgrounds, UI layers in each frame
f. Physics & Collision
– Entity update() methods compute positions, detect overlaps, resolve collisions
g. Audio Manager
– Loads and plays sounds via Pygame.mixer API
h. Packaging & Distribution
– dist/ folder containing PyInstaller-generated executables (Cryprawl-v0.0.4-alpha.1.exe, SkyForce versions)
– compiler_directive.md documents build flags

##### Relationships and Data Flows
- User Input → Game Core (Cryprawl.py event loop)
- Game Core → Entity Modules.update() → Physics & Collision → Entity state changes
- Game Core → Audio Manager.play() on events
- Entity Modules ↔ Asset Management (load images/audio via rpath.py)
- Build Scripts (PyInstaller) → Executable in dist/

##### Architectural Patterns & Principles
- Central Game Loop (Single-threaded main loop)
- Modular Entities (each game object encapsulates its own logic)
- Resource Abstraction (rpath.py + settings.py centralize config & asset paths)
- Separation of Concerns: input, update, render, audio handled in distinct subsystems

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration"
        Settings["settings.py (Configuration Loader)"]:::config
        Rpath["rpath.py (Resource Path Helper)"]:::config
    end

    subgraph "Runtime Subsystems"
        Input["Input Handler"]:::runtime
        Cryprawl["Cryprawl.py (Main Loop)"]:::runtime
        Renderer["Renderer"]:::runtime
        Audio["Audio Manager"]:::runtime
    end

    subgraph "Entity Modules"
        Ship["ship.py"]:::entity
        Bullet["bullet.py"]:::entity
        Enemy["enemy.py"]:::entity
        Bat["bat.py"]:::entity
        Batmage["Batmage.py"]:::entity
        Button["button.py"]:::entity
    end

    subgraph "Asset Store"
        AssetImages["Images"]:::asset
        AssetAudio["Audio"]:::asset
    end

    subgraph "Build & Packaging"
        Docs["compiler_directive.md (Build Flags)"]:::pack
        Build["dist/ (Executables)"]:::pack
    end

    Settings --> Cryprawl
    Rpath --> Cryprawl
    Input -->|"events"| Cryprawl
    Cryprawl -->|"draw()"| Renderer
    Cryprawl -->|"play()"| Audio
    Cryprawl -->|"update()"| Ship
    Cryprawl -->|"update()"| Bullet
    Cryprawl -->|"update()"| Enemy
    Cryprawl -->|"update()"| Bat
    Cryprawl -->|"update()"| Batmage
    Cryprawl -->|"update()"| Button

    Ship -->|"load assets"| AssetImages
    Bullet -->|"load assets"| AssetImages
    Enemy -->|"load assets"| AssetImages
    Bat -->|"load assets"| AssetImages
    Batmage -->|"load assets"| AssetImages
    Button -->|"load assets"| AssetImages

    Ship -->|"load sounds"| AssetAudio
    Bullet -->|"load sounds"| AssetAudio
    Enemy -->|"load sounds"| AssetAudio
    Bat -->|"load sounds"| AssetAudio
    Batmage -->|"load sounds"| AssetAudio
    Button -->|"load sounds"| AssetAudio

    Audio -->|"uses"| AssetAudio

    Cryprawl -->|"build"| Build
    Cryprawl -->|"references"| Docs

    click Settings "https://github.com/phimie/cryprawl/blob/main/settings.py"
    click Rpath "https://github.com/phimie/cryprawl/blob/main/rpath.py"
    click Input "https://github.com/phimie/cryprawl/blob/main/Cryprawl.py"
    click Cryprawl "https://github.com/phimie/cryprawl/blob/main/Cryprawl.py"
    click Renderer "https://github.com/phimie/cryprawl/blob/main/Cryprawl.py"
    click Audio "https://github.com/phimie/cryprawl/blob/main/Cryprawl.py"
    click Ship "https://github.com/phimie/cryprawl/blob/main/ship.py"
    click Bullet "https://github.com/phimie/cryprawl/blob/main/bullet.py"
    click Enemy "https://github.com/phimie/cryprawl/blob/main/enemy.py"
    click Bat "https://github.com/phimie/cryprawl/blob/main/bat.py"
    click Batmage "https://github.com/phimie/cryprawl/blob/main/Batmage.py"
    click Button "https://github.com/phimie/cryprawl/blob/main/button.py"
    click AssetImages "https://github.com/phimie/cryprawl/tree/main/assets/images/"
    click AssetAudio "https://github.com/phimie/cryprawl/tree/main/assets/audio/"
    click Build "https://github.com/phimie/cryprawl/tree/main/dist/"
    click Docs "https://github.com/phimie/cryprawl/blob/main/compiler_directive.md"

    classDef runtime fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef entity fill:#90EE90,stroke:#333,stroke-width:1px
    classDef asset fill:#FFA500,stroke:#333,stroke-width:1px
    classDef config fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef pack fill:#D3D3D3,stroke:#333,stroke-width:1px
```
