Skip to content

Terrain Movement Modifiers

HunterWhitty 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

ss

Traversable and Non-Traversable Terrain

ss

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