summaryrefslogtreecommitdiff
path: root/src/render.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-10-24 23:39:15 +0200
committerPaweł Redman <pawel.redman@gmail.com>2017-10-24 23:39:15 +0200
commit16e1a2f3dd5c08a3847aa635d4bd9dbf83f83c3f (patch)
treef268eb9171bf17817e7b6065870e027a5d834f3f /src/render.cpp
parent6723790daa66c333103f940540ea7ef83a4057d9 (diff)
Tile rendering needs a redoing.
Diffstat (limited to 'src/render.cpp')
-rw-r--r--src/render.cpp57
1 files changed, 3 insertions, 54 deletions
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