11#include < game.hpp>
22#include < glm/gtx/norm.hpp>
33#include < le2d/context.hpp>
4- #include < algorithm>
54#include < cstddef>
65#include < format>
76#include < iterator>
87#include < string>
98#include < vector>
109#include " enemy.hpp"
1110#include " kvf/time.hpp"
12- #include " le2d/asset_loader.hpp"
13- #include " le2d/data_loader.hpp"
1411#include " le2d/drawable/text.hpp"
1512#include " lighthouse.hpp"
1613#include " util/random.hpp"
1714
1815namespace miracle {
1916Game::Game (gsl::not_null<le::ServiceLocator const *> services) : m_services(services), m_lighthouse(services), m_light(services) {
2017 spawn_wave ();
21- auto const & data_loader = services->get <le::IDataLoader>();
22- auto const & context = services->get <le::Context>();
23- auto const asset_loader = le::AssetLoader{&data_loader, &context};
24- m_font = asset_loader.load_font (" fonts/specialElite.ttf" );
18+ auto const & asset_loader = services->get <le::AssetLoader>();
19+ m_font = asset_loader.load <le::IFont>(" fonts/specialElite.ttf" );
20+ if (!m_font) { throw std::runtime_error{" Failed to load font" }; }
2521}
2622
2723void Game::on_cursor_pos (le::event::CursorPos const & cursor_pos) {
@@ -79,7 +75,7 @@ void Game::update_score(int points) {
7975 m_score += points;
8076 m_score_str.clear ();
8177 std::format_to (std::back_inserter (m_score_str), " Score: {}" , m_score);
82- m_score_text.set_string (m_font, m_score_str);
78+ m_score_text.set_string (* m_font, m_score_str);
8379}
8480
8581void Game::update_health_text () {
@@ -95,7 +91,7 @@ void Game::update_health_text() {
9591 std::format_to (std::back_inserter (m_health_str), " Health: {:.1f}" , m_lighthouse.get_health ());
9692 }
9793
98- m_health_text.set_string (m_font, m_health_str);
94+ m_health_text.set_string (* m_font, m_health_str);
9995}
10096
10197} // namespace miracle
0 commit comments