# motion-twin/hammerfest architecture

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

- Interactive diagram: https://gitdiagram.com/motion-twin/hammerfest
- Repository: https://github.com/motion-twin/hammerfest

## Overview

##### Project Type and Purpose
- Hammerfest is a Flash-based video game (developed in MotionTypes for Flash 7/8 – AVM1) originally released in 2006.
- The project contains game logic, entity management, animations, levels, and various gameplay modes handled in ActionScript/MotionTypes files.
- The purpose is to run a complete game experience with rich animations, controlled by the game engine and supported by various assets (graphics, sounds, XML data).

##### Analyzing the File Structure
- The top-level directories include:
- "class": This is the core game code. Inside, you have subdirectories like "hammer", which contain further specific modules (e.g., Animation, Chrono, Loader, GameManager, etc.).
- "class/hammer/entity": Contains various game entities (players, bombs, bosses, different enemy types) further broken down by subdirectories (e.g., "bad", "bomb", "shoot").
- "class/hammer/gui": Focused on user interface elements (Container, Field, GameInterface, etc.).
- "class/hammer/levels" and "xml/levels": Seem to manage level data and scripts.
- "class/hammer/mode": Contains different game modes (Adventure, Editor, Soccer, Tutorial…).
- Additional directories exist for:
- "fla": The Flash source files for animations, graphics, and sound integration.
- "swf": Precompiled SWF files for runtime use.
- "images", "sfx", and "xml": Assets like tiles/graphics, sound effects, and configuration data (language files, level details) for the game.
- A “worldmap” directory which may be offering additional map-based interfaces or external navigation.
- There is also a “compile.bat” script for the build process, indicating a reliance on command-line compilation via MotionTypes.

##### Key Architectural Insights from README
- The README is brief but confirms the Flash game’s foundation and explains the use of MotionTypes.

a. Main Components to Include:
- Game Engine Core:
- Represented mainly by the "class/hammer" folder. Include modules like GameManager, Loader, FxManager, and RandomManager.
- Entity Management:
▪ Player and related controllers.
▪ Enemy (bad) entities segregated by type (general enemies, bomb types, shooter entities, etc.).
▪ Boss entities.
- Level Management:
- “levels” modules from "class/hammer/levels" and "xml/levels" configuration files. Indicate a script processing unit (e.g., ScriptEngine) and data managers.
- Game Modes:
- A component grouping various game modes from "class/hammer/mode" (e.g., Adventure, BossRush, Tutorial, Soccer etc.).
- Graphical User Interface (GUI):
- Based on "class/hammer/gui", show a separate GUI module handling overlays, control panels, and in-game menus.
- Asset Management:
- External assets (graphics from "fla" and "images", sounds from "sfx", and configuration XML from "xml") should be represented as resource providers feeding into the Loader.
- Build & Deployment Pipeline:

b. Relationships and Interactions:
- Game Engine Core to the Entity Management, Levels, and Game Modes – all interacting as part of the runtime.
- Data flow from external asset components (images, sounds, XML) into the Loader and then into the game modules.

c. Architectural Patterns & Design Principles:
- The design suggests a modular pattern where game logic, entities, and modes are clearly separated.
- There is a clear separation between asset management (graphics, sounds, levels) and core game functionality.
- While not explicitly MVC, the division between game engine, entity behavior, and GUI can be represented in distinct layers.

d. Relevant Technologies, Frameworks, & Libraries:
- MotionTypes for Flash 7/8 (AVM1) – the chosen toolset for compiling and managing ActionScript.
- ActionScript (or MotionTypes extensions like .mt files) as the core programming language.
- SWF output files for running the final game.
- XML for configuration data (levels, language, quests, items).

## Diagram (Mermaid)

```mermaid
flowchart TB

    %% Asset Management
    subgraph "Asset Management"
        FAA("Flash Assets"):::asset
        IMG("Images/Graphics"):::asset
        SFX("Sound Files"):::asset
        XMLCONF("XML Configuration"):::asset
    end

    %% Build & Deployment Pipeline
    subgraph "Build & Deployment Pipeline"
        BUILD("Build Script"):::build
        SWF_CONF("SWF Make Config"):::build
        SWF_OUT("SWF Output"):::build
    end

    %% Game Engine Core
    subgraph "Game Engine Core"
        GM("GameManager"):::core
        LD("Loader"):::core
        FX("FxManager"):::core
        RNG("RandomManager"):::core
    end

    %% Entity Management
    subgraph "Entity Management"
        PLAYER("Entity: Player"):::entity
        ENEMY("Entity: Enemy"):::entity
        BOSS("Entity: Boss"):::entity
    end

    %% Level Management
    subgraph "Level Management"
        SCRIPT("ScriptEngine/Levels (Code)"):::level
        LEVEL_CONF("Levels Data (XML)"):::level
    end

    %% Game Modes
    subgraph "Game Modes"
        AD("Adventure Mode"):::mode
        BR("BossRush Mode"):::mode
        SOC("Soccer Mode"):::mode
        TUT("Tutorial Mode"):::mode
    end

    %% Graphical User Interface (GUI)
    subgraph "Graphical User Interface (GUI)"
        CT("Container"):::gui
        GI("GameInterface"):::gui
        FL("Field"):::gui
    end

    %% World Map Interface
    subgraph "World Map Interface"
        WM("World Map"):::world
    end

    %% Connections

    %% Asset Management flows into the Loader inside the Game Engine Core
    FAA --> LD
    IMG --> LD
    SFX --> LD
    XMLCONF --> LD

    %% Loader feeds the overall Game Engine Core
    LD --> GM
    GM --> FX
    GM --> RNG

    %% Game Engine Core drives various subsystems
    GM --> PLAYER
    GM --> ENEMY
    GM --> BOSS
    GM --> SCRIPT
    GM --> AD
    GM --> BR
    GM --> SOC
    GM --> TUT
    GM --> CT
    GM --> GI
    GM --> FL

    %% GUI Interaction with Game Engine Core (bi-directional interaction)
    CT -- "input" --> GM

    %% Build System contributes to the Game Engine Core build process
    BUILD --> GM
    SWF_CONF --> GM
    SWF_OUT --> GM

    %% Asset Management XML also feeds Level Management configuration
    XMLCONF --> LEVEL_CONF

    %% World Map interacts with the GUI
    WM --> CT

    %% Click Events
    click GM "https://github.com/motion-twin/hammerfest/tree/master/class/hammer"
    click PLAYER "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/entity"
    click ENEMY "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/entity"
    click BOSS "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/entity"
    click SCRIPT "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/levels"
    click LEVEL_CONF "https://github.com/motion-twin/hammerfest/tree/master/xml/levels"
    click AD "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/mode"
    click BR "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/mode"
    click SOC "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/mode"
    click TUT "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/mode"
    click CT "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/gui"
    click GI "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/gui"
    click FL "https://github.com/motion-twin/hammerfest/tree/master/class/hammer/gui"
    click FAA "https://github.com/motion-twin/hammerfest/tree/master/fla"
    click IMG "https://github.com/motion-twin/hammerfest/tree/master/images"
    click SFX "https://github.com/motion-twin/hammerfest/tree/master/sfx"
    click XMLCONF "https://github.com/motion-twin/hammerfest/tree/master/xml"
    click BUILD "https://github.com/motion-twin/hammerfest/blob/master/compile.bat"
    click SWF_CONF "https://github.com/motion-twin/hammerfest/blob/master/swfmake.xml"
    click SWF_OUT "https://github.com/motion-twin/hammerfest/tree/master/swf"
    click WM "https://github.com/motion-twin/hammerfest/blob/master/worldmap/map.html"

    %% Styles
    classDef asset fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef build fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef core fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef entity fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef level fill:#d1ecf1,stroke:#333,stroke-width:2px;
    classDef mode fill:#e2e3e5,stroke:#333,stroke-width:2px;
    classDef gui fill:#f5c6cb,stroke:#333,stroke-width:2px;
    classDef world fill:#d6d8db,stroke:#333,stroke-width:2px;
```
