Skip to content

TerrainTile Class

RileyWhitty edited this page Sep 12, 2023 · 6 revisions

TerrainTile

The map is made up of TerrainTiles. Each TerrainTile represents a single tile on the map. The TerrainTile class was a pre-existing class which was included in the base game engine. It has been modified to include several new properties/class variables that represent the TerrainTile's state as well as new methods that can be used by the map entity to retrieve/modify its state.

The TerrainTile class has the following class variables along with their associated class methods for modifying/retrieving these values. All of the methods and class variables are defined in the javadocs.

terrainCategory

This variable is used to store the terrain type of the tile as defined by the public enum TerrainCategory included in the TerrainTile class. The terrainCategory value that a TerrainTile has is used to determine the values of some of the other class variables upon instantiation. It also determines the sprite used to represent the TerrainTile in the game area. There are two methods associated with the terrainCategory class variable, getTerrainCategory and setTerrainCategory which both retrieve and set the variable value respectively.

isTraversable

This class variable is used to store whether a TerrainTile is traversable by any player/NPC entity. It is defined during the TerrainTile initialization based on the terrainCategory value. There is only one method associated with the isTraversable class variable and it is the isTraversable which returns the variable value.

isOccupied

This class variable is used to store whether there is a stationary entity (such as a crop tile) that is located in the same grid position as the TerrainTile. Note that this variable is only a boolean and does not store or reference the entity which is located at the same position if the tile is occupied. There are three methods associated with this class variable, isOccupied, setOccupied, and setUnOccupied which return the value of the variable, set it to true and set it to false respectively.

isTillable

This class variable is used to store whether a tile is tillable or not (can be used to plant crops). This is also defined during the TerrainTile initialization based on the terrainCategory value. It has one associated method, isTillable, which returns the variable value.

cropTile

This class variable is used to store a cropTile entity which occupies the terrainTile. Is set to null when the class is initialised. There are three methods associated with this class variable, getCropTile, setCropTile and removeCropTile which returns the cropTile that occupies the terrainTile, sets the cropTile which occupies the terrainTile and removes the cropTile which occupies the terrainTile respectively.

speedModifier

This class variable is used to store a float speedModifier for entities moving on top of it. It is intended to act as a multiplier for an entities default movement on the TerrainTile. It is set during the initialization of the TerrainTile class. There is one method associated with this class variable, getSpeedModifier which returns the value of speedModifier.

TerrainTile Sprites

These sprites are supposed to display an 'Alien' planet's terrain so not all sprites will look exactly like earth terrain with different colours such as purple being used extensively.

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

Deep Water

image image image

Rock

image image image

Lava

image

Lava Ground

image image image

Gravel

image

Flowing Water

image

Clone this wiki locally