Skip to content

Map Elements

Jared946 edited this page Oct 7, 2026 · 17 revisions

Entities

Platforms

Basic Platform

Overview

This entity represents a basic, static platform that uses a ColliderComponent to interact with the grapple raycast system and a PlatformGrappleComponent to set which sides can be grappled to. Instantiated through the object factory.

Config

  • position (GridPoint2): where to spawn the platform
  • width (int): the width to scale the platform to
  • height (int): the height to scale the platform to
  • grappleSides (int): which sides should be grappleable
  • textureFilePath (String): the asset filepath that should be used at the texture for the platform

Moving Platform

Overview

A platform that moves between two targets at a set speed. Can be activated/deactivated through a trigger button if activation id(s) are specified.

Config

Extends platform, so includes all configuration available on platform here.

  • firstTarget (Vector2): the position in the map that should be the first target for this platform. moves between firstTarget and secondTarget in a loop.
  • secondTarget (Vector2): the position in the map that should be the second target for this platform. moves between secondTarget and firstTarget in a loop.
  • speed (Vector2): a float variable in both x and y that represents how quickly the platform should move on that axis. note: firstTarget and secondTarget should share the same value in either the x or y, and this speed should set the opposite (e.g. firstTarget = (0, 1); secondTarget = (0, 2); speed should set y)
  • activateIds (String[]): all IDs the platform should be triggered by

Crumbling Platform

Overview

A platform that crumbles after a certain amount of time post-contact with the player. Also has a respawn timer that will re-enable the platform after it has crumbled. See here for more information.

Config

Extends platform, so includes all configuration available on platform here.

  • timeBeforeCrumble (float): how long should pass between the player colliding with the entity and the crumbling beginning
  • crumbleTime (float): how long the crumble should take
  • respawnTime (float): how long from the beginning of the whole interaction should the platform take to respawn. Note: the actual time taken is currently respawnTime - (timeBeforeCrumble + crumbleTime). This will be fixed to be more usable and accurate next sprint.

Triggerable Platform

Overview

A platform that has an initial activation state and updates it's visibility/physics collision

Config

Extends platform, so includes all configuration available on platform here.

  • ids (String[]): all IDs the platform should be triggered by
  • initialState (boolean): whether the platform should start on in the level

Slippery Platform

Overview

A platform that causes the player to slide when stopping movement on the platform and has a max grapple time until the grapple is forced to break

Config

Extends platform, so includes all configuration available on platform here.

  • maxGrappleTime: a float representing how many seconds before the grapple should break
  • slipperiness: a float representing the traction that should be applied when decelerating on a slippery platform

Ledge

Overview

A platform type that allows for the player to move up through it and then stand on it as normal. Furthermore, at the player's discretion, they are able to press 'S' whilst standing on a ledge to fall back through it.

Config

Uses platform config, so includes all configuration available on platform here.

Floor/Walls

Overview

Represents solid ground the player can stand on and cannot move through

Config

Uses platform config, so includes all configuration available on platform here.

Sensors

Win Condition

Overview

This entity is implemented as a sensor, rather than a physical object, and uses the NPC physics layer to wait for a player to interact with it's hitbox in order to trigger a signal on the WinCondition component. Instaniated through the object factory.

Level Trigger

Overview

This entity is implemented as a sensor, rather than a physical object, and uses the NPC physics layer to wait for a player to interact with it's hitbox in order to emit a signal with a String representing the next level's name to be loaded by TutorialGameScreen.

Traps

Spikes

Overview

Deals damage to the player when they collide with a spike hitbox. Deals 1 heart of damage.

Config

  • xMin (int): the coordinate for the leftmost column of spikes in the cluster
  • xMax (int): the coordinate for the rightmost columns of spikes in the cluster
  • yMin (int): the coordinate for the bottom row of spikes in the cluster
  • yMax (int): the coordinate for the top row of spikes in the cluster
  • rotation (float): the rotation to apply to the spikes if they should be attached to a wall/roof (Use 0f for floor, 90f for right wall, 180f for roof, 270f for left wall)
  • attached (boolean): whether each individual spike should try and attach to something from the base (rotation included - a 0f spike will shoot it's raycast down, whereas a 180f spike will shoot it's raycast up)

Spiky Ball Trap

Overview

Shoots spiky balls at set intervals that deal 2 hearts of damage. Note: The trap itself deals no damage and has no collision associated with it at all.

Config

  • position (GridPoint2): where to position the trap in the level
  • rotation (float): the rotation to apply to the spikes if they should be attached to a wall/roof (Use 0f for floor, 90f for right wall, 180f for roof, 270f for left wall)
  • ids (String[]): all IDs the platform should be triggered by
  • spawnInterval (float): how frequently in delta time the trap should spawn spiky balls
  • initialState (boolean): whether the platform should start on in the level
  • mode (ActivationMode): the spawn behaviour of the spawn component when it receives an activation attempt. SpikyBallTraps should generally use TOGGLE.

Components

Platforms

PlatformGrappleComponent

A component that can be added to anything with a hitbox and strictly 4 sides. This component allows a hitbox to specify which sides can be grappled to, allowing for the map team to not need to worry about being able to skip parts of the level by just grappling to the end.

Constants

To ease development and improve readability, 4 constants were added:

  • LEFT_SIDE = 8
  • TOP_SIDE = 4
  • RIGHT_SIDE = 2
  • BOTTOM_SIDE = 1

These allow for quick comparison checks against fixed binary representations to ensure the corresponding side is eligible to be hit.

Methods

  • getGrappleSides(): returns the base 10 integer representing which sides can be grappled to
  • updateGrappleSides(int grappleSides): updates this components grappleSides integer. Note: This method and the constructor are clamped to 15 as the maximum grapple sides a platform can have is all 4 (8 + 4 + 2 + 1 = 15)
  • checkSideHit(Entity platform, Vector2 raycastEnd): returns a base 10 integer of either LEFT, TOP, RIGHT, or BOTTOM SIDE representing which side the impact point of the grapple raycast actually hit on the provided platform entity. If no valid point on the platform was found, 0 is returned, meaning the grapple missed the platform. Note: Due to floating point inaccuracies, there is a lenience factor set to 0.005f.
  • calculatePlatformBounds(Entity platform): uses the provided platform entity and calculates the distance from the topLeft to the center of the platform, and uses this to determine the overall bounding box size.
  • successfulGrapple(int hitSide): does a bitwise and to compare the stored grappleable-sides of this component against the side that was hit. If both bits are 1 in the binary representation of grappleSides and hitSide, this method returns true, representing a successful grapple. Note: should generally be called after checkSideHit which returns a hitSide

MovingPlatformComponent

A component that can be added for anything applying to Platform Grapple Component. This component inherits Platform Grapple Component functionality and adds additional functionality allowing it to move. Takes 3 additional parameters: firstTarget, rightTarget, maxSpeed. firstTarget and secondTarget are the two positions the moving platform will rotate between, travelling at a speed equal to maxSpeed.

NOTE: Moving Platform Component currently only works for horizontal or vertical movement only, not diagonal. i.e. either X component of maxSpeed should be 0 or Y component of maxSpeed should be 0.

Methods

  • getDirection() returns the normalised current XY direction of the moving platform. e.g. (-1, 0) for left and (1, 0) for right

CrumblingPlatformComponent

A component that is added to an entity to remove it and add it back (crumble/respawn) when a player collides with it. For any further information, see here.

Methods

  • (Override)update() method to use delta time to track time in each state to appropriately move between crumble/respawn states.
  • crumble() disables the physics component and sets the texture to transparent
  • respawn() re-enables the physics component and resets the texture to the specified platform texture

TriggerablePlatformComponent

Handles activation from trigger buttons based on any id's the entity is configured to respond to, otherwise, acts just like a regular platform

Methods

  • handleActivation(boolean) receives a new state and applies it by enabling/disabling the platform collider and texture

SlipperyPlatformComponent

Handles incrementing how long the player has been grappled to an entity with this component. Also required in PlayerActions.java to test whether the slipperiness deceleration traction should be applied.

Methods

  • setGrappled(boolean) receives a new state and applies it by starting to increment how long the player has been grappled. Useful for the edge case where a player may disconnect manually before the max grapple time is reached.
  • (Override)update() increments current grapple time and emits a signal that the time has been exceeded. If the player is no longer grapple, this resets the state for future grapples.

LedgeComponent

Nothing specified in this component, only used to differentiate ledges from other platforms in the physics collision preSolve() handling.

Sensors

WinConditionComponent

A lightweight component that simply responds to a player hitbox collision by emitting a signal to the UI that the win screen should display. There are no methods to call or ways to interact with this object for now, as it is incredibly simplistic in design.

LevelTriggerComponent

A lightweight component that simply responds to a player hitbox collision by emitting a signal to the GameScreen that a new level should be loaded. There are no ways to call or interact with this object for now, as it is incredibly simplistic in design.

Traps

SpikyBallComponent

Uses delta time to move in a direction specified by the SpikyBallTrap (uses the rotation to figure out which way the ball should move - 0f balls move up, 180f balls move down). The ball ignores gravity to allow for balls to move left and right based on rotation.

Methods

handleDispose() - when this object collides with anything, it schedules the ball for disposal (Override)update() - moves the ball in the specified direction based on a constant speed factor and delta time

Miscellaneous

RotatableMapComponent

Stores a rotation float for the entity, allowing for other components to read the requested rotation and update accordingly. In the future, it will rotate the hitbox of the entity as well, but there are currently some issues with the calculation. This is performed in an initialisation frame (the first frame of update()).

AttachableMapComponent

Stores information about the parent entity the entity with this component found to attach to, it's offset from that parent and whether it has attempted to find a parent yet. When applied to an (the child) entity close to another (the parent) entity that is below it, the child will attach and follow all movements made to the body of that parent entity.

Methods

  • (Override)update() tries to discover a parent to attempt to attach to, or, if attached to a parent, forces the child to make any movements the parent has made since this child last checked
  • discoverParent() shoots a raycast down from its base (accounting for rotation - 0f base = down, 180f = up) and looks for any valid entity within a close enough distance. If it finds any entity close enough, it stores a reference and sets attached to true. Either way, discovery has been attempted and will not be attempted again.
  • moveWithParent() uses the offset from the parent and the parent's new location this frame to calculate whether/how much the child needs to move this frame. this emulates the idea of being attached another entity, and only works if the parent entity is not null.

ActivatableMapComponent

Stores an entity's activation state allowing for any components that require handling activation to respond accordingly. If no array of IDs are provided, or the array is empty, the entity is considered non-activatable, and must remain in the state it was initially set to.

Methods

  • checkID(String[]) ensures the array is not null, and handles setting whether this entity is activatable
  • isActive() returns the current activation state - true if this entity is active.
  • setActive(boolean) updates the activation state with the provided value and emits a signal on the current entity to allow it to respond to the new state. if this entity is considered non-activatable, it will not get updated and a warning will be logged.
  • getIds() returns an array of ids this entity responds to

CheckpointComponent

A component that can be added to an entity that serves as a checkpoint in game. The component takes 2 parameters: collected which is a boolean value representing the collected status of the checkpoint, and position a GridPoint2 value denoting its position in game.

Methods

  • activate() sets collected to true
  • deactivate() sets collected to false
  • isActive() returns collected status
  • getPosition() returns position of checkpoint
  • update() locates player entity and checks if player position is in range of checkpoint position (currently +/- 1 in both x and y directions)

TriggerButtonComponent

Animates the button press through the RotatableAnimationRenderComponent component and emits a pressed signal on all IDs stored by the button when an arrow shot by the player collides with the button.

Methods

  • onCollisionStart() ensures the other colliding fixture is an ArrowProjectile from the player, and debounces any repeat hits, requiring a gap of 300ms before another collision will successfully trigger the button. If these are successful, it loops through all ids in the array and emits a signal for that key that the GameArea responds to. From there, the GameArea loops through all entities with that key and triggers them with the opposite of their current value.

SpawnerComponent

Allows for an entity to spawn children of it's own by providing a number of important parameters when creating a new component of this type. These are explained below, with an example usage:

Parameters

  • ArrayList<Supplier> spawnableEntities: This is a list of methods this spawn component should use to create entities when attempting to spawn a new entity.
  • spawnInterval: how long between spawn attempts (if set to -1, the spawn component will only spawn 1 entity when triggered by it's activation id)
  • maxSpawns: how many total enemies this spawn component should spawn (if set to -1, the spawn component will indefinitely spawn entities each interval)
  • active: the default state of this spawner
  • mode: specifies how to react to an activation made. these are detailed further below

Example SpawnComponent

new SpawnerComponent(new ArrayList<>(List.of(() -> ObstacleFactory.createSpikyBall(direction))), 2f, -1, true, SpawnerComponent.ACTIVATE_MODE.TOGGLE

Activation Mode

  • NORMAL: whatever is provided by the activation attempt is what the activation state is set to on this entity. if handleActivation receives true, active = true, and vice versa.
  • TOGGLE: whatever is provided by the activation attempt is ignored, and it simply responds like a toggle. if handleActivation receives true or false, active = !active

Methods

  • (Overide)update() uses delta time to keep track of when to spawn a new enemy
  • spawnChild() gets a random method from the list of suppliers of spawnable entities, positions them in the exact middle of this spawner component and emits a signal received by the GameArea to spawn an entity through the proper channels.
  • handleActivation(boolean) handles activation attempts as outlined by the Activation Mode section

RespawnComponent

A component that can be added to the player. This component inherits from Component, and acts as a position tracker for the player entity to which it is attached. Currently, it triggers a respawn event and reduces the health of the player if the y position of the player reaches -10 or less.

Methods

  • (Overide)update() checks the entity position and triggers respawn and updates health if requirement is satisfied

RisingWaterComponent

Manages the rising water hazard for level 3 by visually growing the size of the water and moving the hitbox as required.

Methods

  • setCurrentHeight(float) sets the current height and queues it to be reflected visually/hitbox-wise in update()
  • (Overide)update() handles syncing up the visuals of the water and the hitbox always being placed at the top of the water
  • captureValues(int) triggered when a checkpoint is activated on level 3 and determines the safest place to save the water level for (either the current level or within a safe distance from the checkpoint depending on player skill)
  • toggleActivation(boolean) sets the speed to 0 or resumes it's previous speed

Level Configuration

LevelConfig

Overview

Base configuration class used to define all entities and map elements that should be spawned for a level. Extended by each level-specific config to define its layout and contents.

Config

  • platforms: all basic platforms in the level
  • movingPlatforms: all moving platforms in the level
  • crumblingPlatforms: all crumbling platforms in the level
  • triggerablePlatforms: all triggerable platforms in the level
  • ledges: all ledges in the level
  • floors: all floors/walls in the level
  • spikeClusters: all spike clusters in the level
  • spikyBallTraps: all spiky ball traps in the level
  • triggerButtons: all trigger buttons in the level
  • checkpoints: all checkpoints in the level
  • entities: all entities to be spawned into the level

LevelConfig -> Level Config -> GameArea

LevelTutorialConfig

Overview

Extends LevelConfig and defines the layout and configuration for the tutorial level. Contains the positions and configuration of map elements, items and checkpoints used within the tutorial.

Config

  • platform/floor layouts
  • item spawn positions and quantities
  • checkpoint positions
  • traps
  • other tutorial-specific map elements

LevelTutorialConfig -> LevelConfig -> TutorialGameArea

Terrain

Overview

Terrain represents the tiled terrain underneath the entities and map elements spawned by the level config.

TerrainFactory

Creates the terrain used by a GameArea, including the map dimensions, terrain type and placement of individual tiles.

TerrainComponent

Stores the generated tiled map and handles rendering the terrain within the GameArea.

TerrainTile

Represents the different tile types available to the TerrainFactory when generating terrain.

Terrain Type -> TerrainFactory -> TerrainTile -> TerrainComponent -> GameArea

Game Areas

Level1GameArea

Overview

GameArea used for level 1. Loads all required assets, creates the terrain and spawns all entities specified by Level1Config.

Also handles spawning the player, background, camera, UI and level events.

Level1Config -> Level1GameArea -> Spawn Entities -> Run Level

Level2GameArea

Overview

GameArea used for Level 2. Loads all required assets, creates the terrain and spawns all entities specified by the Level 2 configuration.

Also handles spawning the player, background, camera, UI and level events.

Level 2 Config -> Level2GameArea -> Spawn Entities -> Run Level

Level3GameArea

Overview

GameArea used for Level 3. Loads all required assets, creates the terrain and spawns all entities specified by the Level 3 configuration.

Also handles spawning the player, background, camera, UI and level events.

Level 3 Config -> Level3GameArea -> Spawn Entities -> Run Level

Clone this wiki locally