FontWrapper::FontWrapper(SDL_Renderer* rend, const char* path, int size, SDL_Color color, char style) { std::string s_path; if(Globals::IS_DEBUG) { std::string t_path = PROJECT_DIR; s_path = t_path + Globals::PATH_TO_FONTS + path; } else { auto temp = FilePath::getExecFilePath(); temp = temp.substr(0, temp.find_last_of("/") ); s_path = temp + Globals::PATH_TO_FONTS + path; } _font = FC_CreateFont(); FC_LoadFont(_font, rend, s_path.c_str(), size, color, style); }
void PathWorldState::Init() { SetResourcesFilePath("Fonts/nokiafc22.ttf"); fontSmall = FC_CreateFont(); FC_LoadFont(fontSmall, display->renderer, resourcesFilePath, 30, FC_MakeColor(255, 255, 255, 255), TTF_STYLE_NORMAL); fontBig = FC_CreateFont(); FC_LoadFont(fontBig, display->renderer, resourcesFilePath, 40, FC_MakeColor(255, 255, 255, 255), TTF_STYLE_NORMAL); // Initialize Graph Texture graphTexture = {}; StaticTexture_Init(&graphTexture, FIXED_WIDTH, FIXED_HEIGHT, display->renderer); StaticTexture_StartDrawing(&graphTexture); arrowTexture = {}; SetResourcesFilePath("Images/Arrow.png"); if (Texture_LoadFromFile(&arrowTexture, display->renderer, resourcesFilePath) == false) { SDL_Log("Failed to load Image!\n"); } boidTexture = {}; SetResourcesFilePath("Images/Boid.png"); if (Texture_LoadFromFile(&boidTexture, display->renderer, resourcesFilePath) == false) { SDL_Log("Failed to load Image!\n"); } heroTexture = {}; SetResourcesFilePath("Images/Player.png"); if (Texture_LoadFromFile(&heroTexture, display->renderer, resourcesFilePath) == false) { SDL_Log("Failed to load Image!\n"); } startX = 19; startY = 9; origin.x = 170; origin.y = 40; hero.position.x = 20 * labyrinth.cellSize + origin.x + 15; hero.position.y = 9 * labyrinth.cellSize + origin.y + 15; hero.width = heroTexture.width; hero.height = heroTexture.height; initMinotaur(); objective(); std::vector<Node*> camino = PathfindingUtils::PathfindAStar(&labyrinth, &labyrinth.array[startX][startY], &labyrinth.array[endX][endY]); way.pathOccupation = camino.size(); for (int i = 0; i < camino.size(); i++) { way.pathArray[i] = camino[i]->position*labyrinth.cellSize; way.pathArray[i].x += origin.x + 10; way.pathArray[i].y += origin.y + 10; } StaticTexture_EndDrawing(&graphTexture); labyrinth = {}; Grid_Init(&labyrinth); for (int i = 0; i < labyrinth.width; ++i) { for (int j = 0; j < labyrinth.height; ++j) { if (TEMPLATE_1[i][j] == 9) { labyrinth.array[i][j].isWall = true; } else { labyrinth.array[i][j].isWall = false; if (TEMPLATE_1[i][j] != 0) { labyrinth.array[i][j].weight = (float)TEMPLATE_1[i][j]; } } } } hero.simplePath = &way; hero.SetBehaviour(Behaviour::SIMPLE_PATH_FOLLOWING); }