From 16e1a2f3dd5c08a3847aa635d4bd9dbf83f83c3f Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 24 Oct 2017 23:39:15 +0200 Subject: Tile rendering needs a redoing. --- src/render.cpp | 57 +++------------------------------------------------------ 1 file changed, 3 insertions(+), 54 deletions(-) (limited to 'src/render.cpp') diff --git a/src/render.cpp b/src/render.cpp index 819641f..c8513cb 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -7,34 +7,24 @@ static sf::Font font; static void draw_tile(sf::RenderWindow *window, v2f_t x, world::tile_t *tile) { - render::tile_t *tile_assets; sf::Texture *texture; - bool mirror; switch (tile->type) { default: return; case world::TILE_DIRT: - tile_assets = &assets::tile_dirt; + texture = &assets::tile_dirt; break; case world::TILE_WALL: - tile_assets = &assets::tile_wall; + texture = &assets::tile_wall; break; } - texture = tile_assets->get_texture(tile->neighbors, &mirror); - wot_rect.setTexture(texture); wot_rect.setSize(sf::Vector2f(1.0f, 1.0f)); - if (!mirror) { - wot_rect.setPosition(x); - wot_rect.setScale(v2f_t(1, 1)); - } else { - wot_rect.setPosition(x + v2f_t(1.0f, 0)); - wot_rect.setScale(v2f_t(-1, 1)); - } + wot_rect.setPosition(x); wot_rect.setFillColor(sf::Color::White); wot_rect.setOutlineColor(sf::Color::Transparent); window->draw(wot_rect); @@ -274,45 +264,4 @@ void oriented_sprite_4M2_t::load(std::string prefix, size_t xc, size_t yc) textures[1].load(prefix + "_y_", yc); } -void tile_monotonic_t::load(std::string prefix) -{ - texture.loadFromFile(prefix + ".png"); -} - -void tile_connecting12_t::load(std::string prefix) -{ - for (size_t i = 0; i < 12; i++) - textures[i].loadFromFile(prefix + "_" + std::to_string(i) + ".png"); -} - -sf::Texture *tile_monotonic_t::get_texture(int neighbors, bool *mirror) -{ - *mirror = false; - return &texture; -} - -sf::Texture *tile_connecting12_t::get_texture(int neighbors, bool *mirror) -{ - const static struct{ size_t index; bool mirror; } map[16] = { - {0, false}, - {1, false}, - {2, false}, - {3, false}, - {1, true}, - {4, false}, - {3, true}, - {5, false}, - {6, false}, - {7, false}, - {8, false}, - {9, false}, - {7, true}, - {10, false}, - {9, true} - }; - - *mirror = map[neighbors].mirror; - return textures + map[neighbors].index; -} - } // namespace render -- cgit