|
|
@ -3,16 +3,16 @@ |
|
|
|
#include "constants.hpp" |
|
|
|
#include "constants.hpp" |
|
|
|
#include "render.hpp" |
|
|
|
#include "render.hpp" |
|
|
|
|
|
|
|
|
|
|
|
TileMap::TileMap(Config& config, size_t width, size_t height) |
|
|
|
TileMap::TileMap(size_t width, size_t height) : |
|
|
|
: $config(config), |
|
|
|
$config("./assets/tiles.json"), |
|
|
|
$width(width), |
|
|
|
$width(width), |
|
|
|
$height(height), |
|
|
|
$height(height), |
|
|
|
$tile_ids(height, matrix::Row(width, SPACE_VALUE)), |
|
|
|
$tile_ids(height, matrix::Row(width, SPACE_VALUE)), |
|
|
|
$display(height, TileRow(width, "")) |
|
|
|
$display(height, TileRow(width, "")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TileMap::dump(int show_x, int show_y) { |
|
|
|
void TileMap::dump(int show_x, int show_y) { |
|
|
|
SFMLRender::init_terminal(); |
|
|
|
SFMLRender::init_terminal(); |
|
|
|
for(matrix::each_row it{$tile_ids}; it.next();) { |
|
|
|
for(matrix::each_row it{$tile_ids}; it.next();) { |
|
|
@ -33,13 +33,18 @@ void TileMap::load(matrix::Matrix &walls) { |
|
|
|
string tile_name = walls[it.y][it.x] == SPACE_VALUE ? "FLOOR_TILE" : "WALL_TILE"; |
|
|
|
string tile_name = walls[it.y][it.x] == SPACE_VALUE ? "FLOOR_TILE" : "WALL_TILE"; |
|
|
|
|
|
|
|
|
|
|
|
std::wstring tile = $config.wstring(tile_name); |
|
|
|
std::wstring tile = $config.wstring(tile_name); |
|
|
|
std::string tile_s = $config[tile_name]; |
|
|
|
string tile_s = $config[tile_name]; |
|
|
|
|
|
|
|
|
|
|
|
$tile_ids[it.y][it.x] = tile[0]; |
|
|
|
$tile_ids[it.y][it.x] = tile[0]; |
|
|
|
$display[it.y][it.x] = tile_s; |
|
|
|
$display[it.y][it.x] = tile_s; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const string &TileMap::at(size_t x, size_t y) { |
|
|
|
|
|
|
|
return $display[y][x]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool TileMap::INVARIANT() { |
|
|
|
bool TileMap::INVARIANT() { |
|
|
|
dbc::check(matrix::height($tile_ids) == $height, "$tile_ids has wrong height"); |
|
|
|
dbc::check(matrix::height($tile_ids) == $height, "$tile_ids has wrong height"); |
|
|
|
dbc::check(matrix::width($tile_ids) == $width, "$tile_ids has wrong width"); |
|
|
|
dbc::check(matrix::width($tile_ids) == $width, "$tile_ids has wrong width"); |
|
|
|