#include <world_map.h>
Public Member Functions | |
WorldMap () | |
const std::vector< std::vector < MapTile > > & | get_map () |
Private Types | |
typedef std::vector < std::vector< MapTile > > | MapTileMatrix |
Private Member Functions | |
bool | out_of_bounds (int row, int col) |
int | count_in_surrounding_tiles (int row, int col, MapTile tile_type) |
void | starting_noise (int border) |
void | smoothing_pass (MapTile tile_type, int threshold) |
void | generate_land_mass () |
void | set_land_or_water (int row, int col, int mod, bool more_water) |
void | ocean_borders (int border) |
void | generate_beaches () |
Private Attributes | |
std::vector< std::vector < MapTile > > | map |
int | height |
int | width |
A representation of the game's world map. The world map is finite and represented by a two-dimensional array, like literally everything else in the game. The map takes care of its own generation in its constructor, then the map is passed to the outside world by a call to get_map().
|
private |
A self-explanatory typedef for the base model for this class.
WorldMap::WorldMap | ( | ) |
The main constructor, which also generates the world's continents.
|
private |
|
private |
Generates beaches at the borders of all land and water tiles.
|
private |
Generates the main land mass in the water by calling smoothing_pass in sequence with different parameters on both land and water tiles.
const std::vector< std::vector< MapTile > > & WorldMap::get_map | ( | ) |
Returns a reference to the world map.
|
private |
Will generate an ocean border with the given width around the map.
border | - the desired width of the border. |
|
private |
Determines whether a given row-column pair is out of bounds on the world map matrix.
row | |
col |
|
private |
Has a chance of setting a given tile to either a land or water tile. This is for preliminary continent generation in the world.
row | |
col | |
mod | - the inverse of the chance that the given tile will be turned to water/land (for more_water=true/false respectively) |
more_water | - Should be set to 'true' if the given tile should be more likely to be set to water, and 'false' if the given tile should be more likely to be set to land. |
|
private |
Will loop through the world map. On each tile, if the number of surrounding tiles of the given type is greater or equal to the given "threshold", there is a 1/(8 - num_surrounding_tiles) chance that the tile in question will be changed to tile_type. This function is relatively portable, and could be ported to any number of other situations. When applied sequentially with different thresholds (as in generate_land_mass()), will produce a passable world.
tile_type | - the type of tile that will be changed. |
threshold | - The number of surrounding tiles must be greater than this value for any change to occur. |
|
private |
Fills the world map (minus the ocean border) with randomly-placed tiles, then performs the following transformation to all tiles on the map:
?O? ?O? O?O --> OOO ?O? ?O? *
border | - the width of the ocean border surrounding the map. |
|
private |
Height, which is set to WORLD_HEIGHT in the constructor. Essentially just makes the variable less verbose. May be removed.
|
private |
The base model for this class. A two-dimensional matrix storing MapTiles.
|
private |
Width, which is set to WORLD_WIDTH in the constructor. Essentially just makes the variable less verbose. May be removed.