# choiysapple/asteroids-plus architecture

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

- Interactive diagram: https://gitdiagram.com/choiysapple/asteroids-plus
- Repository: https://github.com/choiysapple/asteroids-plus

## Overview

##### Main Components Identification
The system can be broken down into these primary components:

a. Core Game Architecture
- Game Engine (SpriteKit)
- Scene Management
- Game Loop
- Input Handling

b. Game Components
- Sprite Management
- Physics Engine
- Audio System
- HUD System

**┌─────────────────────────────────────┐**
- Game UI                │
- HUD (Score, Life, Asteroids)    │
- Visual Effects                   │
- ┘

**┌─────────────────────────────────────┐**
- Scene Management            │
- ┌──────────┐  ┌──────────┐        │
- Main   │  │   Game   │        │
- Menu   │  │  Scene   │        │
- ┘  └──────────┘        │
- ┘

**┌─────────────────────────────────────┐**
- Core Systems              │
- ┌──────────┐  ┌──────────┐        │
- Physics  │  │  Sprite  │        │
- Engine   │  │ Manager  │        │
- ┘  └──────────┘        │
- ┌──────────┐  ┌──────────┐        │
- Audio   │  │Animation │        │
- System   │  │ System   │        │
- ┘  └──────────┘        │
- ┘

##### Technical Details

Annotations for:
- SpriteKit integration points
- Vector-based sprite implementations
- Physics body definitions
- Sound effect trigger points

##### Implementation Notes

Create callouts for:
- Coordinate system for vector graphics
- Collision detection groups
- Animation system implementation
- State management between scenes

Remember to highlight the modular nature of the code structure as seen in the file tree:
- Base (Core app structure)
- Data (Game constants and types)
- Helper (Utility functions)
- Scene (Game scene management)
- Sound (Audio assets)

This will help other developers understand how the different components interact and how new features can be integrated into the existing architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#FFE5CC,stroke:#FF9933
    classDef core fill:#CCE5FF,stroke:#3399FF
    classDef asset fill:#CCFFCC,stroke:#33CC33
    classDef scene fill:#E5CCFF,stroke:#9933FF
    classDef audio fill:#FFD6E0,stroke:#FF6B88

    %% Legend
    subgraph Legend
        L1[UI Components]:::ui
        L2[Core Systems]:::core
        L3[Asset Management]:::asset
        L4[Scene Management]:::scene
        L5[Audio System]:::audio
    end

    %% Top Layer - User Interface
    subgraph UI
        HUD[HUD System]:::ui
        VFX[Visual Effects]:::ui
        Popup[Popup System]:::ui
    end
    click Popup "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Scene/GameScenePopup.swift"

    %% Middle Layer - Scene Management
    subgraph SceneManagement
        MainMenu[Main Menu Scene]:::scene
        GameScene[Game Scene]:::scene
        SceneManager[Scene Manager]:::scene
    end
    click SceneManagement "https://github.com/ChoiysApple/Asteroids-Plus/tree/main/Asteroid.swiftpm/Scene/"
    click MainMenu "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Scene/MainMenuScene.swift"
    click GameScene "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Scene/GameScene.swift"

    %% Bottom Layer - Core Systems
    subgraph CoreSystems
        Physics[Physics Engine]:::core
        SpriteManager[Sprite Manager]:::core
        AnimSystem[Animation System]:::core
        Constants[Game Constants]:::core
        AsteroidTypes[Asteroid Types]:::core
        Shapes[Sprite Shapes]:::core
    end
    click AnimSystem "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Helper/Animation.swift"
    click Constants "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Data/Constants.swift"
    click AsteroidTypes "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Data/AsteroidType.swift"
    click Shapes "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Data/Shapes.swift"

    %% Asset Management
    subgraph Assets
        GameItems[Game Items]:::asset
        BulletItem[Bullet Item]:::asset
        LifeItem[Life Item]:::asset
    end
    click Assets "https://github.com/ChoiysApple/Asteroids-Plus/tree/main/Asteroid.swiftpm/Assets.xcassets/"
    click BulletItem "https://github.com/ChoiysApple/Asteroids-Plus/tree/main/Asteroid.swiftpm/Assets.xcassets/BulletItem.imageset/"
    click LifeItem "https://github.com/ChoiysApple/Asteroids-Plus/tree/main/Asteroid.swiftpm/Assets.xcassets/LifeItem.imageset/"

    %% Audio System
    subgraph AudioSystem
        SoundEffects[Sound Effects]:::audio
        AsteroidHit[Asteroid Hit]:::audio
        BulletUp[Bullet Up]:::audio
        Fire[Fire Sound]:::audio
        LifeUp[Life Up]:::audio
        ShipHit[Ship Hit]:::audio
        WaveStart[Wave Start]:::audio
    end
    click AudioSystem "https://github.com/ChoiysApple/Asteroids-Plus/tree/main/Asteroid.swiftpm/Sound/"
    click AsteroidHit "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Sound/AsteroidHit.wav"
    click BulletUp "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Sound/BulletUp.wav"
    click Fire "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Sound/Fire.wav"
    click LifeUp "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Sound/LifeUp.wav"
    click ShipHit "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Sound/ShipHit.wav"
    click WaveStart "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Sound/WaveStart.wav"

    %% Base App Structure
    subgraph AppBase
        AppEntry[App Entry Point]:::core
        ContentView[Main Content View]:::core
    end
    click AppEntry "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Base/MyApp.swift"
    click ContentView "https://github.com/ChoiysApple/Asteroids-Plus/blob/main/Asteroid.swiftpm/Base/ContentView.swift"

    %% Relationships
    AppEntry --> ContentView
    ContentView --> SceneManager
    SceneManager --> MainMenu
    SceneManager --> GameScene
    GameScene --> HUD
    GameScene --> VFX
    GameScene --> Popup
    GameScene --> Physics
    GameScene --> SpriteManager
    GameScene --> AnimSystem
    GameScene --> SoundEffects
    SpriteManager --> GameItems
    Constants --> GameScene
    AsteroidTypes --> GameScene
    Shapes --> SpriteManager
```
