Skip to content

Speed Zones

kacymaster edited this page Oct 22, 2025 · 6 revisions

1. Structural Decoupling

  • Dedicated Map<String, Float> structures isolate speed modifiers, letting keyWaypoints retain only navigation pivots and visual anchors.
  • Rendering helpers (markKeypoint, markPathTile) touch only waypoint visuals and invalid-tile bookkeeping, so slow zones can change without repaint side effects.
  • Mirror logic in MapEditor2 keeps the second lane’s geometry and speed changes equally independent.

Sources: source/core/src/main/com/csse3200/game/areas/MapEditor.java


2. Unified Path Generation

  • generateEnemyPath() composes both geometric routes and speed modifiers in one pass, creating waypoint entities only when a coordinate is either a key turn or a speed-zone marker.
  • connectWaypointsWithPath() / connectWaypoints2WithPath() emit path tiles via generatePathBetweenPoints, keeping the visual lane and speed logic locked together.
  • ForestGameArea.spawnPlayer() and ForestGameArea2.spawnPlayer() consume the finished waypointList, so every factory receives synchronized data.

Sources: source/core/src/main/com/csse3200/game/areas/MapEditor source/core/src/main/com/csse3200/game/areas2/MapTwo/ForestGameArea2


3. Obstacles & Invalid-Zone Integration

  • Game areas spawn crystals and snow trees while registering their coordinates via registerBarrierCoords / registerSnowTreeCoords, keeping the MapEditor invalid grid aligned with scene obstacles.
  • placementController.refreshInvalidTiles() merges pathTiles, barriers, snow trees, and snow tiles, ensuring build UI and highlight overlays honor both paths and scenery.

Sources: source/core/src/main/com/csse3200/game/areas/ForestGameArea source/core/src/main/com/csse3200/game/areas/MapEditor


4. Enemy Speed Restoration

  • Enemies slow only while inside a waypoint carrying SpeedWaypointComponent; once absent, WaypointComponent falls back to the factory’s default speed (e.g., GruntEnemyFactory.DEFAULT_SPEED).
  • Unit coverage (EnemySpeedWaypointTest#gruntEnemySlowsDownAtSpeedWaypoint) verifies the slowdown to (0.4f, 0.4f) and implicitly the automatic recovery when leaving the slow zone.

Sources: source/core/src/main/com/csse3200/game/entities/factories/GruntEnemyFactory.java Sure! Here's the English version in Markdown format, following the exact style of your previous sections:


5. Swamp Slow-Zone Dynamic Visual Overlay

  • Swamp slow tiles are visually highlighted using a procedurally generated pulse effect, rendered above the terrain to indicate movement penalties clearly.
  • The overlay features scaling ripples, alpha breathing, and inner highlight animation, simulating viscous swamp terrain without requiring any external textures or art assets.
  • All visuals are handled by SlowZoneVisualComponent.update() and draw(), while the radial texture is generated once in ensureRegion() and shared across all swamp tiles to minimize GPU cost.
  • This system is purely visual — enemy slowdown is still governed exclusively by SpeedWaypointComponent, ensuring gameplay logic remains decoupled from visual effects.

Sources: source/core/src/main/com/csse3200/game/components/effects/SlowZoneVisualComponent.java source/core/src/main/com/csse3200/game/entities/factories/SlowZoneEffectFactory.java source/core/src/main/com/csse3200/game/areas/ForestGameArea.java


UML Diagram

image

Clone this wiki locally