Skip to content

Terrain Movement Modifiers

Radius-XT edited this page Sep 12, 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. Firstly, the Vector2 representing the player entity's position on the map is retrieved and transformed so that it is pointing to the bottom of the player entity's sprite feet. Then, the speed modifier for the tile at the transformed Vector2 coordinate (retrieved using getTile() and then getSpeedModifier() methods) is used to scale the existing velocityScale. This velocityScale is used scale the speed of the player entity, resulting in the terrain speed modifier being applied to the movement speed of the player entity.

Movement Modifiers for non-Player entities

Movement modifiers are applied to non-player entities through the PhysicsMovementComponent class. However, it was not implemented during Sprint2. This is because the PhysicsMovementComponent and none of it's variables stored a pointer to the GameMap class, preventing the use of the getTile methods to get the speedModifier value. This will be fixed next sprint after the GameMap class has been slightly overhauled to allow for easier access of variables.

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 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.1

image image image

Dirt Movement Speed: 0.7

image image image

Shallow Water Movement Speed: 0.9

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: 1.3

image

Clone this wiki locally