Class BaseLevelGameArea

java.lang.Object
com.csse3200.game.areas.GameArea
com.csse3200.game.areas.BaseLevelGameArea
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Direct Known Subclasses:
BossLevelGameArea, LevelOneGameArea, LevelThreeGameArea, LevelTwoGameArea, TutorialGameArea

public abstract class BaseLevelGameArea extends GameArea
Base game area for standardised JSON-driven levels. This class is responsible for:
  1. Loading asset files (LevelAssetsConfig) and level config (LevelConfig),
  2. Building terrain and world boundaries,
  3. Spawning HUD/minimap/music,
  4. Spawning entities via SpawnRegistry and creating the player,
  5. Constructing parallax background from ParallaxConfig.

Concrete levels provide file paths via configPath(), assetsPath() ()} and parallaxPath()

  • Field Details

    • gridFactory

      protected final GridFactory gridFactory
    • rs

      protected final ResourceService rs
    • cfg

      protected LevelConfig cfg
    • assets

      protected LevelAssetsConfig assets
    • parallax

      protected ParallaxConfig parallax
    • MAP_SIZE

      protected final com.badlogic.gdx.math.GridPoint2 MAP_SIZE
    • PLAYER_SPAWN

      protected final com.badlogic.gdx.math.GridPoint2 PLAYER_SPAWN
    • WALL_THICKNESS

      protected float WALL_THICKNESS
  • Constructor Details

    • BaseLevelGameArea

      protected BaseLevelGameArea(GridFactory gf)
      Create a new base level area.
      Parameters:
      gf - grid factory used to construct tile maps and collision
  • Method Details

    • configPath

      protected abstract String configPath()
    • assetsPath

      protected abstract String assetsPath()
    • parallaxPath

      protected abstract String parallaxPath()
    • loadAssets

      protected void loadAssets()
      Load all assets declared in LevelAssetsConfig.
      Specified by:
      loadAssets in class GameArea
    • loadPrerequisites

      protected void loadPrerequisites()
      Read level configs, construct grid, spawn walls/HUD/minimap, and start music.
      Specified by:
      loadPrerequisites in class GameArea
      Throws:
      NullPointerException - if any required JSON cannot be loaded
    • loadEntities

      protected void loadEntities()
      Spawn parallax (if configured) and all entities declared in LevelConfig.entities, then add a ground floor.
      Specified by:
      loadEntities in class GameArea
      Throws:
      IllegalStateException - if cfg has not been loaded
      IllegalArgumentException - if the config has no entities array
    • spawnPlayer

      protected Entity spawnPlayer()
      Create a new player with default components and register level spawners.
      Specified by:
      spawnPlayer in class GameArea
      Returns:
      the newly created player entity
    • spawnPlayer

      protected Entity spawnPlayer(List<Component> components)
      Create a new player using provided components and register level spawners.
      Specified by:
      spawnPlayer in class GameArea
      Parameters:
      components - list of components to attach to the new player (e.g., inventory)
      Returns:
      the newly created player entity
    • dispose

      public void dispose()
      Dispose of area resources and unload all assets declared in the asset manifest.

      Calls GameArea.dispose() to dispose entities, then unloads textures/atlases/sounds/music

      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class GameArea
    • buildTerrain

      protected GridComponent buildTerrain(com.badlogic.gdx.math.GridPoint2 mapSize)
      Build the basic terrain.

      Default implementation creates an invisible collision terrain using a placeholder tile sourced from images/empty.png.

      Parameters:
      mapSize - desired map size in tiles (width, height)
      Returns:
      constructed terrain component ready to be spawned
    • buildParallax

      protected void buildParallax()
      Build a parallax background from ParallaxConfig, if provided.

      Each layer is scaled to at least fill the current camera viewport, then multiplied by the per-layer scale. Missing or unloaded textures are skipped.

    • spawnLaserShower

      public void spawnLaserShower(float x, float y, float delay)
      Spawns in the laser shower on the level based on the players position.

      This function is called within MainGameScreen where it determines what level it is on and the frequency at which to spawn the lasers.

    • laserShowerChecker

      public void laserShowerChecker(float x, float y, float delay)