# stevedabartender/milkquest3 architecture

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

- Interactive diagram: https://gitdiagram.com/stevedabartender/milkquest3
- Repository: https://github.com/stevedabartender/milkquest3

## Overview

##### Project Type and Purpose
- This is a GameMaker Studio 2 game project (“Milk Quest: Half & Half”).
- It’s a monolithic, event-driven game built in GML (.gml/.yy scripts), containing resources (sprites, sounds, shaders, tilesets) and rooms (levels).
- The codebase includes managers for autoscrolling, cutscenes, input, saving/loading, and platform-specific build targets.

##### Top-Level Architectural Components
a. GameMaker Runtime & Build Targets
- Platform Export Modules: html5, windows, mac, linux, operagx (options/* directories)
b. Resource Manager
- Sprites (sprites/)
- Sounds (sounds/)
- Shaders (shaders/)
- Tilesets & Rooms (tilesets/, rooms/)
- Fonts (fonts/)
- Datafiles (e.g., text script datafiles/dScriptText.txt)
c. Script Library (scripts/)
- Utility scripts (input, collision, GUI drawing)
- Game logic scripts (change_room, save/load, objective checks)
- Character-specific scripts (jump, drive, punch, AI)
d. Object Layer (objects/)
- Manager objects (oPersistent, oCamera, oCutsceneManagerMQ2, oAutoscrollerManager, oSaveDesk)
- Gameplay objects (oPlayer, oEnemy, pickups, traps, NPCs, checkpoints)
e. Room/Level Layer (rooms/)
- Entry-point rooms (rMainMenu, rLevelSelect, rTitle)
- Level rooms (rChristmasLevel1, rFactory2Main, rFezTower, etc.)
- Triggered via change_room scripts

##### Relationships & Data Flow
1. Startup: Platform Loader → Resource Manager loads assets → Persistent object initializes game state
2. Main Menu Room: oTitleManager handles menu input → invokes change_room script
3. Room Load: change_room → instantiate appropriate room (.yy) → instance creation code → objects spawn
4. Game Loop (per frame):
- Input Manager script (getInput) feeds events to player NPC objects
- Each object’s Step event calls relevant scripts (movement, AI, collisions)
5. Managers coordinate higher-level events: oCutsceneManagerMQ2 runs timelines/timelines/ on triggers → dialogues via call_textbox
6. Save/Load: save_game_data / load_game_data invoked on checkpoints or menu actions

##### Architectural Patterns & Principles
- Separation of concerns:
- Resource directories vs. logic scripts vs. platform options
- Manager objects encapsulate cross-cutting concerns (camera, saving, cutscenes)
- Reusable script library: Many objects call common scripts (standard_collision, draw_gui).
- Layered Room Design: Backdrops, tile layers, instance layers, GUI overlays

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Engine & Build Targets
    subgraph "Engine & Build Targets"
        direction TB
        GMRuntime["GameMaker Runtime<br/>(Core Game Loop)"]:::engine
        options_main["options/main"]:::engine
        options_html5["options/html5"]:::engine
        options_windows["options/windows"]:::engine
        options_mac["options/mac"]:::engine
        options_linux["options/linux"]:::engine
        options_operagx["options/operagx"]:::engine
    end

    %% Resource Manager
    subgraph "Resource Manager"
        direction TB
        Sprites["Sprites"]:::resource
        Sounds["Sounds"]:::resource
        Shaders["Shaders"]:::resource
        Tilesets["Tilesets"]:::resource
        Fonts["Fonts"]:::resource
        Datafiles["Datafiles"]:::resource
    end

    %% Script Library
    subgraph "Script Library"
        direction TB
        getInput["getInput.gml"]:::script
        standard_collision["standard_collision.gml"]:::script
        draw_gui["draw_gui.gml"]:::script
        change_room["change_room.gml"]:::script
        save_game_data["save_game_data.gml"]:::script
        load_game_data["load_game_data.gml"]:::script
        call_textbox["call_textbox.gml"]:::script
    end

    %% Object Layer
    subgraph "Object Layer"
        direction TB
        subgraph "Manager Objects"
            direction TB
            oPersistent["oPersistent"]:::manager
            oCamera["oCamera"]:::manager
            oCutsceneManager["oCutsceneManagerMQ2"]:::manager
            oAutoscrollerManager["oAutoscrollerManager"]:::manager
            oSaveDesk["oSaveDesk"]:::manager
            oTitleManager["oTitleManager"]:::manager
        end
        subgraph "Gameplay Entities & Triggers"
            direction TB
            oPlayer["oPlayer"]:::gameplay
            oEnemy["oEnemy"]:::gameplay
            oCheckpoint["oCheckpoint"]:::gameplay
            oDialogueTrigger["oDialogueTrigger"]:::gameplay
            oCutsceneTrigger["oCutsceneTrigger"]:::gameplay
        end
    end

    %% Room/Level Layer
    subgraph "Room/Level Layer"
        direction TB
        rMainMenu["rMainMenu"]:::room
        rLevelSelect["rLevelSelect"]:::room
        rTitle["rTitle"]:::room
        rChristmas["rChristmasLevel1"]:::room
        rFactory["rFactory2Main"]:::room
        rFezTower["rFezTower"]:::room
        rTest["rTest"]:::room
    end

    %% Connections
    GMRuntime -->|loads assets| Sprites
    GMRuntime --> Sounds
    GMRuntime --> Shaders
    GMRuntime --> Tilesets
    GMRuntime --> Fonts
    GMRuntime --> Datafiles

    GMRuntime --> change_room
    GMRuntime --> getInput

    getInput -->|feeds input| oPlayer
    getInput --> oEnemy

    oPlayer -->|calls| standard_collision
    oPlayer --> draw_gui
    oEnemy --> standard_collision

    oPersistent -->|manages state| save_game_data
    oPersistent --> load_game_data

    oCutsceneManager --> call_textbox
    oCutsceneManager --> change_room

    oTitleManager --> change_room
    oTitleManager --> rMainMenu

    change_room -->|loads room| rMainMenu
    change_room --> rLevelSelect
    change_room --> rChristmas
    change_room --> rFactory
    change_room --> rFezTower
    change_room --> rTest

    %% Click Events for component mapping
    click options_main "https://github.com/stevedabartender/milkquest3/blob/master/options/main/options_main.yy"
    click options_html5 "https://github.com/stevedabartender/milkquest3/blob/master/options/html5/options_html5.yy"
    click options_windows "https://github.com/stevedabartender/milkquest3/blob/master/options/windows/options_windows.yy"
    click options_mac "https://github.com/stevedabartender/milkquest3/blob/master/options/mac/options_mac.yy"
    click options_linux "https://github.com/stevedabartender/milkquest3/blob/master/options/linux/options_linux.yy"
    click options_operagx "https://github.com/stevedabartender/milkquest3/blob/master/options/operagx/options_operagx.yy"

    click Datafiles "https://github.com/stevedabartender/milkquest3/blob/master/datafiles/dScriptText.txt"
    click Fonts "https://github.com/stevedabartender/milkquest3/tree/master/fonts/"
    click Sprites "https://github.com/stevedabartender/milkquest3/tree/master/sprites/"
    click Sounds "https://github.com/stevedabartender/milkquest3/tree/master/sounds/"
    click Shaders "https://github.com/stevedabartender/milkquest3/tree/master/shaders/"
    click Tilesets "https://github.com/stevedabartender/milkquest3/tree/master/tilesets/"
    click rMainMenu "https://github.com/stevedabartender/milkquest3/blob/master/rooms/rMainMenu/rMainMenu.yy"
    click rLevelSelect "https://github.com/stevedabartender/milkquest3/blob/master/rooms/rLevelSelect/rLevelSelect.yy"
    click rTitle "https://github.com/stevedabartender/milkquest3/blob/master/rooms/rTitle/rTitle.yy"
    click rChristmas "https://github.com/stevedabartender/milkquest3/blob/master/rooms/rChristmasLevel1/rChristmasLevel1.yy"
    click rFactory "https://github.com/stevedabartender/milkquest3/blob/master/rooms/rFactory2Main/rFactory2Main.yy"
    click rFezTower "https://github.com/stevedabartender/milkquest3/blob/master/rooms/rFezTower/rFezTower.yy"
    click rTest "https://github.com/stevedabartender/milkquest3/blob/master/rooms/rTest/rTest.yy"

    click getInput "https://github.com/stevedabartender/milkquest3/blob/master/scripts/getInput/getInput.gml"
    click standard_collision "https://github.com/stevedabartender/milkquest3/blob/master/scripts/standard_collision/standard_collision.gml"
    click draw_gui "https://github.com/stevedabartender/milkquest3/blob/master/scripts/draw_gui/draw_gui.gml"
    click change_room "https://github.com/stevedabartender/milkquest3/blob/master/scripts/change_room/change_room.gml"
    click save_game_data "https://github.com/stevedabartender/milkquest3/blob/master/scripts/save_game_data/save_game_data.gml"
    click load_game_data "https://github.com/stevedabartender/milkquest3/blob/master/scripts/load_game_data/load_game_data.gml"
    click call_textbox "https://github.com/stevedabartender/milkquest3/blob/master/scripts/call_textbox/call_textbox.gml"

    click oPersistent "https://github.com/stevedabartender/milkquest3/blob/master/objects/oPersistent/oPersistent.yy"
    click oCamera "https://github.com/stevedabartender/milkquest3/blob/master/objects/oCamera/oCamera.yy"
    click oCutsceneManager "https://github.com/stevedabartender/milkquest3/blob/master/objects/oCutsceneManagerMQ2/oCutsceneManagerMQ2.yy"
    click oAutoscrollerManager "https://github.com/stevedabartender/milkquest3/blob/master/objects/oAutoscrollerManager/oAutoscrollerManager.yy"
    click oSaveDesk "https://github.com/stevedabartender/milkquest3/blob/master/objects/oSaveDesk/oSaveDesk.yy"
    click oTitleManager "https://github.com/stevedabartender/milkquest3/blob/master/objects/oTitleManager/oTitleManager.yy"

    click oPlayer "https://github.com/stevedabartender/milkquest3/blob/master/objects/oPlayer/oPlayer.yy"
    click oEnemy "https://github.com/stevedabartender/milkquest3/blob/master/objects/oEnemy/oEnemy.yy"
    click oCheckpoint "https://github.com/stevedabartender/milkquest3/blob/master/objects/oCheckpoint/oCheckpoint.yy"
    click oDialogueTrigger "https://github.com/stevedabartender/milkquest3/blob/master/objects/oDialogueTrigger/oDialogueTrigger.yy"
    click oCutsceneTrigger "https://github.com/stevedabartender/milkquest3/blob/master/objects/oCutsceneTrigger/oCutsceneTrigger.yy"

    classDef engine fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef resource fill:#a2d2ff,stroke:#0366d6,stroke-width:1px
    classDef script fill:#b7e4c7,stroke:#2d6a4f,stroke-width:1px
    classDef manager fill:#ffb4a2,stroke:#9b2226,stroke-width:1px
    classDef gameplay fill:#ffba08,stroke:#a55b00,stroke-width:1px
    classDef room fill:#e0baff,stroke:#6a0dad,stroke-width:1px
```
