Skip to content

Commit

Permalink
Fixed hardcoded font in the engine (#57)
Browse files Browse the repository at this point in the history
* Fixed hardcoded font in the engine

* Updated engine
  • Loading branch information
Peter-JanGootzen authored and Bram-Boris committed Dec 9, 2019
1 parent fe261eb commit 54c98f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/entities/entity_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class EntityFactory {
const std::vector<Character> getAvailableCharacters() const;
const std::vector<std::pair<Character, bool>> getPickedCharacters() const;

inline static const std::string FONT_PATH = "./assets/fonts/Roboto-Bold.ttf";
private:
std::shared_ptr<EntityManager> entityManager;
RenderableFactory& renderableFactory;
Expand All @@ -69,4 +70,4 @@ class EntityFactory {
SpawnComponent::CreateCompsFn createSniperComponents;
};

#endif // FILE_ENTITY_FACTORY_HPP
#endif // FILE_ENTITY_FACTORY_HPP
4 changes: 2 additions & 2 deletions lib/controllers/game_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ GameController::GameController() {

this->delta_time_modifier = std::unique_ptr<double>(new double(1));

engine = std::make_unique<BrickEngine>("Beast Arena", SCREEN_WIDTH, SCREEN_HEIGHT, layers, fps_cap);
engine = std::make_unique<BrickEngine>("Beast Arena", SCREEN_WIDTH, SCREEN_HEIGHT, layers, fps_cap, EntityFactory::FONT_PATH);
engine->start();
entityManager = std::make_shared<EntityManager>();
entityFactory = std::make_shared<EntityFactory>(entityManager, *engine->getRenderableFactory());
Expand Down Expand Up @@ -452,4 +452,4 @@ void GameController::loadEndGameLevel() {
void GameController::showHighscores() {
scene_manager->destroyAllScenes();
scene_manager->createScene<HighscoreScene>(*entityManager, *entityFactory, *engine, *score_json, *this);
}
}
4 changes: 2 additions & 2 deletions lib/entities/entity_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ std::vector<EntityComponents> EntityFactory::createButton(std::string text, Colo
}
{
auto dstText = std::unique_ptr<Rect>(new Rect{ 0, 0 , 0, 0});
auto rText = renderableFactory.createText(text, font_size, text_color, (int)Layers::Foreground, std::move(dstText));
auto rText = renderableFactory.createText(FONT_PATH, text, font_size, text_color, (int)Layers::Foreground, std::move(dstText));

auto comps = std::make_unique<std::vector<std::unique_ptr<Component>>>();
// Relative to button
Expand All @@ -277,7 +277,7 @@ std::vector<EntityComponents> EntityFactory::createButton(std::string text, Colo

EntityComponents EntityFactory::createText(std::string text, Color color, int font_size, int x, int y, int x_scale, int y_scale, double relative_modifier) {
auto dst = std::unique_ptr<Rect>(new Rect{ 0, 0 , 0, 0});
auto r_text = renderableFactory.createText(text, font_size, color, (int)Layers::UI, std::move(dst));
auto r_text = renderableFactory.createText(FONT_PATH, text, font_size, color, (int)Layers::UI, std::move(dst));
auto comps = std::make_unique<std::vector<std::unique_ptr<Component>>>();
comps->push_back(std::make_unique<TransformComponent>(x / relative_modifier, y / relative_modifier, x_scale / relative_modifier, y_scale / relative_modifier, Direction::POSITIVE, Direction::POSITIVE));
comps->push_back(std::make_unique<TextureComponent>(std::move(r_text)));
Expand Down

0 comments on commit 54c98f7

Please sign in to comment.