Clean up System::render_map.
This commit is contained in:
parent
aa72cfe4a4
commit
2802a44ba4
2 changed files with 9 additions and 9 deletions
|
@ -17,6 +17,7 @@ constexpr const int LIGHT_MULTIPLIER=2.5;
|
||||||
constexpr const float AIMED_AT_BRIGHTNESS=0.2f;
|
constexpr const float AIMED_AT_BRIGHTNESS=0.2f;
|
||||||
constexpr const int MAP_TILE_DIM=64;
|
constexpr const int MAP_TILE_DIM=64;
|
||||||
constexpr const int ICONGEN_MAP_TILE_DIM=64;
|
constexpr const int ICONGEN_MAP_TILE_DIM=64;
|
||||||
|
constexpr const int PLAYER_SPRITE_DIR_CORRECTION=270;
|
||||||
|
|
||||||
constexpr const int BOSS_VIEW_WIDTH=1080;
|
constexpr const int BOSS_VIEW_WIDTH=1080;
|
||||||
constexpr const int BOSS_VIEW_HEIGHT=SCREEN_HEIGHT;
|
constexpr const int BOSS_VIEW_HEIGHT=SCREEN_HEIGHT;
|
||||||
|
|
17
systems.cpp
17
systems.cpp
|
@ -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) {
|
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 width = matrix::width(tiles);
|
||||||
unsigned int height = matrix::height(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();
|
auto render_size = render.getSize();
|
||||||
|
|
||||||
if(render_size.x != width || render_size.y != height) {
|
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.");
|
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();) {
|
for(matrix::each_row it{tiles}; it.next();) {
|
||||||
wchar_t display = tiles[it.y][it.x];
|
wchar_t display = tiles[it.y][it.x];
|
||||||
if(display == L' ') continue; // skip for now
|
if(display == L' ') continue; // skip for now
|
||||||
auto& sprite = textures::get_map_sprite(display);
|
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);
|
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);
|
auto& sprite = textures::get_map_sprite(display);
|
||||||
|
|
||||||
if(display == player_display) {
|
if(display == player_display) {
|
||||||
sf::Vector2f size = sprite.getLocalBounds().size;
|
sf::Vector2f center{float(tile_sprite_dim.x / 2), float(tile_sprite_dim.y / 2)};
|
||||||
sf::Vector2f center{size.x / 2, size.y / 2};
|
float degrees = (((compass_dir * 45) + PLAYER_SPRITE_DIR_CORRECTION) % 360);
|
||||||
float degrees = (((compass_dir * 45) + 270) % 360);
|
|
||||||
|
|
||||||
sprite.setOrigin(center);
|
sprite.setOrigin(center);
|
||||||
sprite.setRotation(sf::degrees(degrees));
|
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 {
|
} 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);
|
render.draw(sprite);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue