Skip to content

Terrain Movement Modifiers

HunterWhitty edited this page Oct 17, 2023 · 16 revisions

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

image image image image

Beach

image image image

Grass

image image image

Dirt

image image image

Shallow Water

image image image

Desert

image image image

Snow

image image image

Ice

image image

Lava Ground

image image image

Gravel

image

Flowing Water

image

The following tiles are not traversable and hence have no movement modifier.

Deep Water

image image image

Rock

image image image

Lava

image

Movement Modifiers

Path Movement Speed: 1.2

image image image image

Beach Movement Speed: 0.9

image image image

Grass Movement Speed: 1.0

image image image

Dirt Movement Speed: 1.0

image image image

Shallow Water Movement Speed: 0.4

image image image

Desert Movement Speed: 0.8

image image image

Snow Movement Speed: 0.8

image image image

Ice Movement Speed: 1.5

image image

Lava Ground Movement Speed: 0.7

image image image

Gravel Movement Speed: 1

image

Flowing Water Movement Speed: 0.4

image

Sequence Diagram for Movement Modifiers

Screenshot 2023-09-12 at 1 01 58 pm

Clone this wiki locally