Nocturna
    Preparing search index...

    GameScene manages the main singleplayer gameplay loop in Nocturna.

    Responsibilities:

    • Loads and initializes the level, cube, parent node, and player.
    • Handles the main game loop, including state transitions (loading, selection, in-game).
    • Manages all game objects, their updates, and collisions.
    • Sets up cameras (multiple FollowCameras) and allows switching between them.
    • Handles score calculation with time-based multipliers.
    • Manages the HUD (health bar, timer, etc.) and background music.
    • Observes and reacts to collisions (coins, enemies, victory, etc.).
    • Supports restarting, retrying, and quitting the level.
    • Implements interfaces for level loading, object observation, collision, and HUD events.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    activeCameraIndex: number = 0
    cameras: FollowCamera[] = []
    cube: Cube
    engine: Engine

    The Babylon.js engine instance.

    gameObjects: GameObject[] = []
    hpBar: HpBar
    inputHandler: InputHandler

    Handles user input for the scene.

    levelLoader: LevelLoader
    multiplicators: number[] = ...
    parent: ParentNode
    player: Player
    scene: Scene

    The Babylon.js scene instance.

    sceneName: string = "level2.json"
    score: number = 0
    timeMultiplicator: number = ...
    timer: number = 0
    win: boolean = false

    Methods

    • Initializes Havok physics for the scene with high gravity and a fixed timestep. Should be called asynchronously.

      Returns Promise<void>

    • Checks if the player has lost (is dead).

      Returns boolean

      True if the player is dead, false otherwise.

    • Checks if the player has won the level.

      Returns boolean

      True if the player has won, false otherwise.

    • Loads a level from a file.

      Parameters

      • file: string

        The level file to load.

      Returns void

    • Indicates if there is a next level (always false in this scene).

      Returns boolean

      False.

    • Loads the level using the LevelLoader.

      Parameters

      • file: string

        The level file to load.

      Returns void

    • Fully resets and reloads the scene (for retry/continue).

      Returns Promise<void>

    • Removes physics bodies from all objects and disables the physics engine.

      Returns void

    • Sets up collision callbacks for all game objects.

      Returns void

    • Sets up custom key actions for the scene.

      Returns void

    • Starts the in-game timer and displays the timer UI.

      Returns void

    • Main update loop for the scene. Handles state transitions.

      Parameters

      • dt: number

        Delta time since last update.

      Returns void

    • Updates the in-game timer and its display.

      Parameters

      • dt: number

        Delta time since last update.

      Returns void

    • Static factory to create and initialize a new GameScene.

      Parameters

      • engine: Engine

        The Babylon.js engine.

      • inputHandler: InputHandler

        The input handler.

      Returns Promise<BaseScene>

      The created and initialized GameScene.