Crumbling Platforms Level‐2 - UQcsse3200/2026-studio-2 GitHub Wiki

CRUMBLING PLATFROMS:

OVERVIEW: Crumbling Platforms are interactive platforms that provide temporary support to the player before disappearing. They are designed to add a time-based challenge to level traversal, requiring the player to move to another platform before the current platform collapses. The crumbling platform behaviour is implemented using the "CrumblingPlatformComponent". This component can be added to a platform entity to give it temporary behaviour while still using the existing platform, physics, and collision systems.

The platform follows a repeating lifecycle:

Stable → Crumbling → Removed → Respawning → Stable

  1. Stable – The platform is active and can be used by the player.
  2. Crumbling – After the configured timeBeforeCrumble, the platform begins to crumble.
  3. Removed – After crumbleTime expires, the platform disappears and can no longer be used.
  4. Respawning– After the configured respawn period, the platform is recreated/restored.
  5. Stable– Once respawned, the platform becomes active again and the cycle can repeat.

This allows the crumbling platform to provide a recurring gameplay challenge rather than permanently disappearing from the level.

FLOW DIAGRAM:

Platform Created | v [ STABLE ] | | timeBeforeCrumble v [ CRUMBLING ] | | crumbleTime v [ REMOVED ] | | respawn delay v [ RESPAWNING ] | v [ STABLE ] | └────────── cycle repeats

PURPOSE:

The crumbling platform mechanic provides:

A temporary platform that cannot be safely used indefinitely. Additional timing and movement challenges for the player. A reusable platform behaviour that can be configured for different levels. Integration with the existing Entity Component System (ECS). Compatibility with the game's existing physics and collision systems.

The behaviour is particularly useful for level sections where the player needs to make quick decisions or move between multiple platforms.

IMPLEMENTATION: The crumbling platform is implemented using a dedicated:

CrumblingPlatformComponent

This component is attached to a platform entity and controls the platform's crumble behaviour.

The platform itself remains a normal physics entity. The component is responsible for determining when the platform should begin crumbling and when it should be removed.

This follows the game's ECS architecture by keeping the crumbling behaviour separate from the platform's basic entity and physics configuration.

PLATFORM CONFIGURATION:

A crumbling platform is created as a normal platform entity and then configured with the CrumblingPlatformComponent.

A simplified example is:

platform .addComponent(new ColliderComponent().setLayer(PhysicsLayer.GROUND)) .addComponent( new CrumblingPlatformComponent( grappleSides, timeBeforeCrumble, crumbleTime, respawnTime));

platform.getComponent(PhysicsComponent.class) .setBodyType(BodyType.StaticBody);

The platform therefore contains both its normal platform/physics configuration and the additional crumbling and respawning behaviour.

CONFIGURATION PARAMETERS:

The CrumblingPlatformComponent accepts configuration values that control how the platform behaves throughout its lifecycle.

grappleSides

Determines which sides of the platform can interact with the player's grappling mechanic.

This allows the crumbling platform to retain the same interaction rules as other platforms in the game.

timeBeforeCrumble

Defines how long the platform remains stable before it begins to crumble.

A larger value gives the player more time to use the platform, while a smaller value creates a more time-critical challenge.

crumbleTime

Defines how long the platform remains in its crumbling state before it is removed.

This allows the visual/behavioural crumble period to be separated from the initial delay.

respawnTime

Defines how long the platform remains removed before it respawns.

After the respawnTime has elapsed, the platform is restored and becomes available for the player to use again.

A shorter respawnTime causes the platform to return sooner, while a longer respawnTime creates a longer period where the platform is unavailable.

BEHAVIOUR AND STATE FLOW:

The platform progresses through the following states.

  1. Stable

When the platform is first created or has finished respawning, it behaves like a normal platform.

The player can:

Stand on the platform. Move across it. Use it as part of the level traversal. Interact with it using the available platform mechanics.

The platform remains stable until the crumble condition is triggered.

  1. Crumbling

After the configured timeBeforeCrumble period, the platform enters its crumbling state.

During this state, the platform is approaching removal and provides the player with a limited amount of time to leave it.

The duration of this state is controlled by crumbleTime.

  1. Removed

Once the crumble timer expires, the platform is removed.

The player can no longer use the platform while it is removed.

The platform then begins waiting for its configured respawn time.

  1. Respawning

After the configured respawnTime has elapsed, the platform respawns.

The platform is restored to its active state so that the player can use it again.

  1. Stable

After respawning, the platform returns to its stable state.

The lifecycle can then repeat whenever the platform is triggered again.

INTEGRATION WITH PHYSICS:

The platform uses the existing physics system rather than implementing a separate collision system.

The platform is configured as a static physics body:

platform.getComponent(PhysicsComponent.class) .setBodyType(BodyType.StaticBody);

Its collision is assigned to the ground physics layer:

new ColliderComponent().setLayer(PhysicsLayer.GROUND)

This allows the player to interact with the platform using the same collision system as other platforms.

The crumbling behaviour therefore controls the platform's lifecycle without duplicating the game's existing physics functionality.

When the platform is removed, it is no longer available for normal platform interaction. When it respawns, its platform functionality is restored.

INTEGRATION WITH ENTITY COMPONENT SYSTEM:

The mechanic follows the ECS design used throughout the project.

The platform entity is responsible for representing the platform, while components provide its individual properties and behaviours.

The crumbling and respawning behaviour is encapsulated in:

CrumblingPlatformComponent

This means the same behaviour can be reused on multiple platform entities.

For example:

Platform Entity │ ├── PhysicsComponent ├── ColliderComponent ├── RenderComponent └── CrumblingPlatformComponent

This separation makes the implementation easier to maintain and allows the crumbling and respawning behaviour to be added without changing the underlying platform implementation.

LEVEL DESIGN USAGE:

Crumbling platforms can be placed in sections where the player is required to move continuously.

They are particularly useful for:

Creating timed platforming sections. Preventing the player from remaining in one location indefinitely. Increasing difficulty during traversal. Encouraging quick movement decisions. Creating risk/reward platform routes. Combining temporary platforms with other hazards. Creating platform sequences that require repeated traversal.

Multiple crumbling platforms can also be placed together to create a sequence where the player must move from one platform to another before the previous platform disappears.

Because the platforms respawn, the same section can remain playable after the platform has disappeared and returned.

EXAMPLE USE CASE:

A platform can be configured with different timing values depending on the intended difficulty.

For example:

new CrumblingPlatformComponent( grappleSides, timeBeforeCrumble, crumbleTime, respawnTime)

The timing parameters control the complete lifecycle of the platform:

timeBeforeCrumble ↓ Platform starts crumbling ↓ crumbleTime ↓ Platform removed ↓ respawnTime ↓ Platform respawns

A level designer can therefore change the timing values without changing the underlying crumbling-platform implementation.

This allows the same component to be reused throughout different sections of the game while providing different gameplay experiences.

DESIGN CONSEDERATIONS:

The crumbling platform was designed to keep platform behaviour modular.

Instead of implementing the crumble and respawn logic directly inside the level or platform creation code, the behaviour is encapsulated inside its own component.

This provides several advantages:

Reusability The component can be attached to multiple platforms. Maintainability Crumbling and respawning logic is kept separate from general platform and physics logic. Configurability Different platforms can use different crumble and respawn timings. ECS compatibility The mechanic follows the project's existing entity-component architecture. Physics compatibility The platform continues to use the existing physics and collision systems. Repeatable gameplay Platforms can return after being removed, allowing the mechanic to be reused during gameplay rather than permanently removing part of the level.

TESTING: The crumbling platform should be tested by verifying the following behaviour.

Platform Creation:

The platform appears in the correct location. The platform has the correct collision behaviour. The player can stand on the platform.

Crumble Timing:

The platform remains stable for the configured timeBeforeCrumble. The platform enters the crumbling state at the expected time. The crumbling state lasts for the configured crumbleTime.

Platform Removal:

The platform is removed after the crumble timer expires. The player can no longer stand on or interact with the removed platform. No unexpected collision remains after the platform disappears.

Respawning:

The platform remains unavailable during the configured respawnTime. The platform respawns after the configured respawn period. The respawned platform is usable by the player. The platform can enter the crumble cycle again after respawning.

Gameplay Integration:

The player can move between multiple crumbling platforms. The platform works correctly with the game's existing movement and physics. Grappling interactions behave correctly according to grappleSides. Repeated crumble and respawn cycles do not cause unexpected behaviour.

SUMMARY:

The crumbling platform mechanic provides a reusable temporary-platform behaviour implemented through CrumblingPlatformComponent.

The component allows each platform to define:

Which sides support grappling. How long the platform remains stable. How long the platform remains in its crumbling state. How long the platform remains removed before respawning.

The resulting platform lifecycle is:

         ┌─────────────────────┐
         │                     │
         v                     │
      STABLE                   │
         │                     │
         │ timeBeforeCrumble   │
         v                     │
    CRUMBLING                  │
         │                     │
         │ crumbleTime         │
         v                     │
      REMOVED                  │
         │                     │
         │ respawnTime         │
         v                     │
    RESPAWNING ────────────────┘

After respawing , the platform returns to stable state and lifecycle can repeat.