# tejon-company/tejon-jumper architecture

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

- Interactive diagram: https://gitdiagram.com/tejon-company/tejon-jumper
- Repository: https://github.com/tejon-company/tejon-jumper

## Overview

##### Project’s Type and Purpose
- This project is a 2D platformer video game built in Python.
- It’s structured as a game application with distinct components for asset management, game scenes (levels and UI), game logic (like physics and interactions), and sprites (characters, enemies, projectiles, environments).
- The README makes it clear that the game has multiple levels, in-game menus, and utilizes different assets (graphics, sounds, level files) organized in the file tree.

##### Main Components
a. Core Engine & Game Loop – Centered around src/main.py.
b. Resource Management – src/resource_manager.py which likely handles asset loading (graphics, audio, and tilemaps).
c. Scenes & Levels – The “src/scene” folder includes background, camera, level, game over screen, and UI subcomponents (HUD, menus like main, pause, settings, victory). These represent different game states and transitions.
d. Singletons and Game Management – Located in src/singletons (director, game, settings modules). They play a critical role in coordinating the game flow and maintaining global settings (like resolution, difficulty).
e. Sprites – Managed in src/sprites, with separate directories for berries, characters (players, enemies split into multiple types), the environment, and projectiles. This separation defines the visual and behavioral components.
f. Assets – The assets folder (with subdirectories for different resolutions and media types) which is used to supply backgrounds, sprite sheets, tiled maps, and sound effects/music.

##### Relationships and Interactions
- The main game loop (src/main.py) initializes the game and loads the required resources via the Resource Manager.
- The Resource Manager interacts with the files in the assets directory to load graphics, sounds, and tile maps.
- Game scenes (like level, game over, and menus) transition between each other under the coordination of the Director and other Singleton managers.
- Within scenes, game objects (sprites) are managed and updated. Sprites (players, enemies, projectiles, etc.) communicate with scene utilities (such as collision and animation utilities) for interactions.
- Singletons (director, game, settings) provide a global point of control to manage state and configuration, thereby bridging requests from the input (e.g., from the control handlers in the scene modules) to the game logic and resource management.

##### Architectural Patterns & Design Principles Highlighted
- Modularity: Clear separation between scenes, resource handling, and sprite management.
- Singleton Pattern: Used in the src/singletons folder for global game controllers and settings.
- Layering: Different layers for game assets (visual and sound), logic (scenes and main loop), and data (configuration/settings).

- Game Initialization (main.py) at the top.
- Core Modules:
- Resource Manager
- Singleton Controllers (Director, Game, Settings)
- Main Game Loop
- Game Scenes:
- Background, Camera, Level, Game Over
- UI Components (HUD, Main Menu, Pause Menu, Settings Menu, Victory Menu)
- Sprites:
- Characters (Player, Enemies – categorized by enemy type)
- Berries (and associated factories)
- Environment Elements
- Projectiles (with pooling support)
- Asset Management:
- Graphics (sprite sheets, backgrounds, tiled maps)
- Audio (music, sound effects)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Modules
    GI["Game Initialization"]:::core
    RM["Resource Manager"]:::resource
    GI --> RM

    %% Singleton Controllers
    subgraph "Singleton Controllers"
      DIRECTOR["Director"]:::singleton
      GAMECTRL["Game Controller"]:::singleton
      SETTINGS["Settings"]:::singleton
      DIRECTOR --> GAMECTRL
      GAMECTRL --> SETTINGS
    end
    RM --> DIRECTOR

    %% Game Scenes
    subgraph "Game Scenes"
      BG["Background"]:::scene
      CAM["Camera"]:::scene
      LVL["Level"]:::scene
      GO["Game Over"]:::scene
      UI["UI - HUD&Menus"]:::scene
      BG --> CAM
      CAM --> LVL
      LVL --> GO
      GO --> UI
    end
    DIRECTOR --> BG

    %% Sprites
    subgraph "Sprites"
      CHAR["Characters"]:::sprite
      BERR["Berries"]:::sprite
      ENV["Environment"]:::sprite
      PROJ["Projectiles"]:::sprite
      CHAR --> BERR
      BERR --> ENV
      ENV --> PROJ
    end
    UI --> CHAR

    %% Assets and Documentation
    A["Assets"]:::asset
    DOC["Documentation"]:::doc
    RM --> A
    A --> DOC
    DIRECTOR --> DOC

    %% Click Events
    click GI "https://github.com/tejon-company/tejon-jumper/blob/develop/src/main.py"
    click RM "https://github.com/tejon-company/tejon-jumper/blob/develop/src/resource_manager.py"
    click DIRECTOR "https://github.com/tejon-company/tejon-jumper/tree/develop/src/singletons"
    click BG "https://github.com/tejon-company/tejon-jumper/tree/develop/src/scene"
    click CHAR "https://github.com/tejon-company/tejon-jumper/tree/develop/src/sprites"
    click A "https://github.com/tejon-company/tejon-jumper/tree/develop/assets"
    click DOC "https://github.com/tejon-company/tejon-jumper/tree/develop/docs/diagrams"

    %% Styles
    classDef core fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef resource fill:#cceeff,stroke:#333,stroke-width:2px;
    classDef singleton fill:#ffebcc,stroke:#333,stroke-width:2px;
    classDef scene fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef sprite fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef asset fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef doc fill:#e0e0e0,stroke:#333,stroke-width:2px;
```
