Package com.csse3200.game.areas
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
Base game area for standardised JSON-driven levels. This class is responsible for:
- Loading asset files (
LevelAssetsConfig) and level config (LevelConfig), - Building terrain and world boundaries,
- Spawning HUD/minimap/music,
- Spawning entities via
SpawnRegistryand creating the player, - Constructing parallax background from
ParallaxConfig.
Concrete levels provide file paths via configPath(), assetsPath() ()} and
parallaxPath()
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LevelAssetsConfigprotected LevelConfigprotected final GridFactoryprotected final com.badlogic.gdx.math.GridPoint2protected ParallaxConfigprotected final com.badlogic.gdx.math.GridPoint2protected final ResourceServiceprotected floatFields inherited from class com.csse3200.game.areas.GameArea
areaEntities, combatStats, deathLocations, grid, inventory, isResetting, player, tileBounds -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate a new base level area. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Stringprotected voidBuild a parallax background fromParallaxConfig, if provided.protected GridComponentbuildTerrain(com.badlogic.gdx.math.GridPoint2 mapSize) Build the basic terrain.protected abstract Stringvoiddispose()Dispose of area resources and unload all assets declared in the asset manifest.voidlaserShowerChecker(float x, float y, float delay) protected voidLoad all assets declared inLevelAssetsConfig.protected voidSpawn parallax (if configured) and all entities declared inLevelConfig.entities, then add a ground floor.protected voidRead level configs, construct grid, spawn walls/HUD/minimap, and start music.protected abstract StringvoidspawnLaserShower(float x, float y, float delay) Spawns in the laser shower on the level based on the players position.protected EntityCreate a new player with default components and register level spawners.protected EntityspawnPlayer(List<Component> components) Create a new player using provided components and register level spawners.Methods inherited from class com.csse3200.game.areas.GameArea
create, createMinimap, createWithPlayer, getComponents, getDeathLocations, getEvents, getMapBounds, getPlayer, recordDeathLocation, reset, saveComponents, setDeathMarkerTexture, spawnDeathMarker, spawnDeathMarkers, spawnEntity, spawnEntityAt, trigger
-
Field Details
-
gridFactory
-
rs
-
cfg
-
assets
-
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
Create a new base level area.- Parameters:
gf- grid factory used to construct tile maps and collision
-
-
Method Details
-
configPath
-
assetsPath
-
parallaxPath
-
loadAssets
protected void loadAssets()Load all assets declared inLevelAssetsConfig.- Specified by:
loadAssetsin classGameArea
-
loadPrerequisites
protected void loadPrerequisites()Read level configs, construct grid, spawn walls/HUD/minimap, and start music.- Specified by:
loadPrerequisitesin classGameArea- Throws:
NullPointerException- if any required JSON cannot be loaded
-
loadEntities
protected void loadEntities()Spawn parallax (if configured) and all entities declared inLevelConfig.entities, then add a ground floor.- Specified by:
loadEntitiesin classGameArea- Throws:
IllegalStateException- ifcfghas not been loadedIllegalArgumentException- if the config has noentitiesarray
-
spawnPlayer
Create a new player with default components and register level spawners.- Specified by:
spawnPlayerin classGameArea- Returns:
- the newly created player entity
-
spawnPlayer
Create a new player using provided components and register level spawners.- Specified by:
spawnPlayerin classGameArea- 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 -
buildTerrain
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 fromParallaxConfig, 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
MainGameScreenwhere 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)
-