diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-12-14 14:09:07 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-12-14 14:09:07 +0100 |
commit | 154004ae6ac3747769648511cdc77e7171c684d8 (patch) | |
tree | a85cd8be5ee9c83e31f028ee9ffdf0ea1269e4ce /src/game/interface.cpp | |
parent | 12143c33141a9c35e8eb01609062655f560b4bc1 (diff) |
The gamelog, being reworking combat.
Diffstat (limited to 'src/game/interface.cpp')
-rw-r--r-- | src/game/interface.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/game/interface.cpp b/src/game/interface.cpp index 854b620..a367607 100644 --- a/src/game/interface.cpp +++ b/src/game/interface.cpp @@ -131,4 +131,35 @@ void state_t::tick(double dt) select.rect[1] = wmouse; } +void state_t::print(std::string str) +{ + log.push_back((log_entry_t){game->now, str}); + std::cout << str << std::endl; +} + +void state_t::render_to(render::state_t *render) +{ + size_t w = window->getSize().x, h = window->getSize().y; + v2f_t x; + + window->setView(sf::View(sf::FloatRect(0, 0, w, h))); + em = std::min(w, h) * 0.04; + + if (select.selecting) + render->render_hlrect(select.rect, sf::Color(200, 100, 50)); + + for (auto i = log.begin(); i != log.end(); ) { + if (i->time + 3 < game->now) + i = log.erase(i); + else + i++; + } + + x = v2f_t(0.0f, 0.0f); + for (log_entry_t &entry : log) { + render->render_text(x, em, entry.text, render::ALIGN_LEFT_TOP, sf::Color::White); + x[1] += em; + } +} + } // namespace interface |