# ameyvibs/run-n-gun architecture

> Architecture diagram of the GitHub repository ameyvibs/run-n-gun, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ameyvibs/run-n-gun
- Repository: https://github.com/ameyvibs/run-n-gun

## Overview

##### Main Components Identification

a) Game Core Systems
- Game Manager (obj_game)
- Camera System (obj_camera)
- Transition System (obj_transition)
- Menu System (obj_menu)

b) Player Systems
- Player Controller (obj_player)
- Gun Mechanics (obj_gun)
- Player States (running, air, dead)

c) Enemy Systems
- Skeleton Enemy (obj_skeleton)
- Skeleton Gun (obj_skeleton_gun)
- Enemy Projectiles (obj_skeleton_bullet)

d) Environment Systems
- Ground/Collision (obj_ground)
- Triggers (obj_trigger)
- Signs (obj_sign)

e) Effect Systems
- Particle Effects (obj_dust, obj_hitspark)
- Sound System
- Screen Shake

##### Component Relationships

**[Game Manager]**

- [Camera System]

- [Player Systems] ←→ [Gun System]

- [Effect Systems]

- [Enemy Systems] ←→ [AI Controller]

- [Effect Systems]

- [Environment Systems]

##### Technical Details
- Resource management (sprites, sounds, fonts)
- Input handling system
- Collision system
- Shader system (shd_white)

##### Implementation Notes
- Annotations for critical scripts like srp_kill_player and srp_slide_transition

##### Architectural Patterns to Highlight
- Event-driven architecture (GameMaker's event system)
- Object-oriented design (parent-child relationships between objects)
- State machine pattern (player and enemy states)

##### Room transitions and game flow

This approach will create a comprehensive visualization of the game's architecture while maintaining the specific requirements of a GameMaker Studio 2 project structure.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        GameManager["Game Manager"]:::core
        Camera["Camera System"]:::core
        Transition["Transition System"]:::core
        Menu["Menu System"]:::core
    end

    subgraph "Player Systems"
        Player["Player Controller"]:::player
        Gun["Gun Mechanics"]:::player
        subgraph "Player States"
            Running["Running State"]:::state
            Air["Air State"]:::state
            Dead["Dead State"]:::state
        end
    end

    subgraph "Enemy Systems"
        Skeleton["Skeleton Enemy"]:::enemy
        SkeletonGun["Skeleton Gun"]:::enemy
        Projectiles["Enemy Projectiles"]:::enemy
    end

    subgraph "Environment"
        Ground["Ground/Collision"]:::env
        Triggers["Triggers"]:::env
        Signs["Signs"]:::env
    end

    subgraph "Effects"
        Particles["Particle Effects"]:::effect
        ScreenShake["Screen Shake"]:::effect
        SoundSystem["Sound System"]:::effect
        subgraph "Particle Types"
            Dust["Dust"]:::effect
            HitSpark["Hit Spark"]:::effect
        end
        subgraph "Sounds"
            DeathSound["Death Sound"]:::effect
            JumpSound["Jump Sound"]:::effect
            ShootSound["Shoot Sound"]:::effect
        end
    end

    subgraph "Room Flow"
        MenuRoom["Menu Room"]:::room
        MainLevel["Main Level"]:::room
        EndingRoom["Ending Room"]:::room
    end

    GameManager --> Camera
    GameManager --> Player
    GameManager --> Skeleton
    GameManager --> Ground
    
    Player --> Gun
    Player --> Running
    Player --> Air
    Player --> Dead
    
    Skeleton --> SkeletonGun
    SkeletonGun --> Projectiles
    
    Player --> Particles
    Skeleton --> Particles
    
    Particles --> Dust
    Particles --> HitSpark
    
    SoundSystem --> DeathSound
    SoundSystem --> JumpSound
    SoundSystem --> ShootSound
    
    MenuRoom --> MainLevel
    MainLevel --> EndingRoom

    %% Click Events
    click GameManager "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_game/obj_game.yy"
    click Camera "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_camera/obj_camera.yy"
    click Transition "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_transition/obj_transition.yy"
    click Menu "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_menu/obj_menu.yy"
    click Player "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_player/obj_player.yy"
    click Gun "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_gun/obj_gun.yy"
    click Running "https://github.com/ameyvibs/Run-n-Gun/blob/main/sprites/spr_player_run/spr_player_run.yy"
    click Air "https://github.com/ameyvibs/Run-n-Gun/blob/main/sprites/spr_player_air/spr_player_air.yy"
    click Dead "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_player_dead/obj_player_dead.yy"
    click Skeleton "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_skeleton/obj_skeleton.yy"
    click SkeletonGun "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_skeleton_gun/obj_skeleton_gun.yy"
    click Projectiles "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_skeleton_bullet/obj_skeleton_bullet.yy"
    click Ground "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_ground/obj_ground.yy"
    click Triggers "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_trigger/obj_trigger.yy"
    click Signs "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_sign/obj_sign.yy"
    click Dust "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_dust/obj_dust.yy"
    click HitSpark "https://github.com/ameyvibs/Run-n-Gun/blob/main/objects/obj_hitspark/obj_hitspark.yy"
    click ScreenShake "https://github.com/ameyvibs/Run-n-Gun/blob/main/scripts/srp_screenshake/srp_screenshake.yy"
    click DeathSound "https://github.com/ameyvibs/Run-n-Gun/blob/main/sounds/snd_death/snd_death.yy"
    click JumpSound "https://github.com/ameyvibs/Run-n-Gun/blob/main/sounds/snd_jump/snd_jump.yy"
    click ShootSound "https://github.com/ameyvibs/Run-n-Gun/blob/main/sounds/snd_shoot/snd_shoot.yy"
    click MenuRoom "https://github.com/ameyvibs/Run-n-Gun/blob/main/rooms/room_menu/room_menu.yy"
    click MainLevel "https://github.com/ameyvibs/Run-n-Gun/blob/main/rooms/room0/room0.yy"
    click EndingRoom "https://github.com/ameyvibs/Run-n-Gun/blob/main/rooms/room_ending/room_ending.yy"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef player fill:#2ecc71,stroke:#27ae60,color:white
    classDef enemy fill:#e74c3c,stroke:#c0392b,color:white
    classDef env fill:#795548,stroke:#5d4037,color:white
    classDef effect fill:#9b59b6,stroke:#8e44ad,color:white
    classDef state fill:#f1c40f,stroke:#f39c12,color:black
    classDef room fill:#34495e,stroke:#2c3e50,color:white
```
