|
|
|
@ -569,10 +569,10 @@ void System::draw_map(GameLevel& level, Matrix& grid, EntityGrid& entity_map) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void System::render_map(Matrix& tiles, EntityGrid& entity_map, sf::RenderTexture& render, int compass_dir, wchar_t player_display) { |
|
|
|
|
sf::Vector2i size{MAP_TILE_DIM,MAP_TILE_DIM}; |
|
|
|
|
sf::Vector2i tile_sprite_dim{MAP_TILE_DIM,MAP_TILE_DIM}; |
|
|
|
|
unsigned int width = matrix::width(tiles); |
|
|
|
|
unsigned int height = matrix::height(tiles); |
|
|
|
|
sf::Vector2u dim{width * size.x, height * size.y}; |
|
|
|
|
sf::Vector2u dim{width * tile_sprite_dim.x, height * tile_sprite_dim.y}; |
|
|
|
|
auto render_size = render.getSize(); |
|
|
|
|
|
|
|
|
|
if(render_size.x != width || render_size.y != height) { |
|
|
|
@ -580,13 +580,13 @@ void System::render_map(Matrix& tiles, EntityGrid& entity_map, sf::RenderTexture |
|
|
|
|
dbc::check(worked, "Failed to resize map render target."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render.clear({0,0,0,0}); |
|
|
|
|
render.clear({0,0,0,255}); |
|
|
|
|
|
|
|
|
|
for(matrix::each_row it{tiles}; it.next();) { |
|
|
|
|
wchar_t display = tiles[it.y][it.x]; |
|
|
|
|
if(display == L' ') continue; // skip for now
|
|
|
|
|
auto& sprite = textures::get_map_sprite(display); |
|
|
|
|
sprite.setPosition({float(it.x * size.x), float(it.y * size.y)}); |
|
|
|
|
sprite.setPosition({float(it.x * tile_sprite_dim.x), float(it.y * tile_sprite_dim.y)}); |
|
|
|
|
render.draw(sprite); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -594,15 +594,14 @@ void System::render_map(Matrix& tiles, EntityGrid& entity_map, sf::RenderTexture |
|
|
|
|
auto& sprite = textures::get_map_sprite(display); |
|
|
|
|
|
|
|
|
|
if(display == player_display) { |
|
|
|
|
sf::Vector2f size = sprite.getLocalBounds().size; |
|
|
|
|
sf::Vector2f center{size.x / 2, size.y / 2}; |
|
|
|
|
float degrees = (((compass_dir * 45) + 270) % 360); |
|
|
|
|
sf::Vector2f center{float(tile_sprite_dim.x / 2), float(tile_sprite_dim.y / 2)}; |
|
|
|
|
float degrees = (((compass_dir * 45) + PLAYER_SPRITE_DIR_CORRECTION) % 360); |
|
|
|
|
|
|
|
|
|
sprite.setOrigin(center); |
|
|
|
|
sprite.setRotation(sf::degrees(degrees)); |
|
|
|
|
sprite.setPosition({float(point.x * size.x) + center.x, float(point.y * size.y) + center.y}); |
|
|
|
|
sprite.setPosition({float(point.x * tile_sprite_dim.x) + center.x, float(point.y * tile_sprite_dim.y) + center.y}); |
|
|
|
|
} else { |
|
|
|
|
sprite.setPosition({float(point.x * size.x), float(point.y * size.y)}); |
|
|
|
|
sprite.setPosition({float(point.x * tile_sprite_dim.x), float(point.y * tile_sprite_dim.y)}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
render.draw(sprite); |
|
|
|
|