Terrain Movement Modifiers - UQcsse3200/2023-studio-1 GitHub Wiki
Terrain Movement Modifiers Overview
The TerrainTile
class contains a private float speedModifier variable which is used to represent a speed modifier to be applied to entities traversing on top of the tile. It is to act as a simple multiplier which should be used to scale the velocity vector of entities. The speedModifier attribute is accessed through the GameMap
class using the getTile method to return a TerrainTile and the getSpeedModifier method to get the speed modifier.
The TerrainTile
class also contains a private boolean isTraversable value which is used to determine if a tile is traversable or not. Non-traversable tiles are enforced via the spawning of 'invisible' entities which have collision boxes to prevent players from moving onto the tiles. The spawning of these entities is handled in the SpaceGameArea
class, using the getNonTraversableTileCoordinates() from the GameMap
class to get a list of non-traversable tiles and spawning an invisible entity using the createInvisibleObstacle() method from the ObstacleFactory
for each non-traversable coordinate.
Movement Modifiers for PlayerClass
Movement modifiers are applied to the player entity through the PlayerActions
class using the updateSpeed() method.
Movement Modifiers for non-Player entities
Movement modifiers are applied to non-player entities through the PhysicsMovementComponent
class using the updateSpeed() method. This method includes a check to only apply terrain movement modifiers to non-flying entities since flying entities fly above the terrain.
Traversable and Non-Traversable Terrain
The following tiles are traversable.
Path
Beach
Grass
Dirt
Shallow Water
Desert
Snow
Ice
Lava Ground
Gravel
Flowing Water
The following tiles are not traversable and hence have no movement modifier.
Deep Water
Rock
Lava
Movement Modifiers
Path Movement Speed: 1.2
Beach Movement Speed: 0.9
Grass Movement Speed: 1.0
Dirt Movement Speed: 1.0
Shallow Water Movement Speed: 0.4
Desert Movement Speed: 0.8
Snow Movement Speed: 0.8
Ice Movement Speed: 1.5
Lava Ground Movement Speed: 0.7