diff --git a/scenes/assets_loader.c b/scenes/assets_loader.c index 8093c84..cc762da 100644 --- a/scenes/assets_loader.c +++ b/scenes/assets_loader.c @@ -7,6 +7,7 @@ typedef enum AssetInfoType TEXTURE_INFO, SPRITE_INFO, SOUND_INFO, + FONT_INFO, EMITTER_INFO, LEVELPACK_INFO, INVALID_INFO @@ -80,6 +81,8 @@ static inline AssetInfoType_t get_asset_type(const char* str) if (strcmp(str, "LevelPack") == 0) return LEVELPACK_INFO; + if (strcmp(str, "Font") == 0) return FONT_INFO; + return INVALID_INFO; } @@ -272,12 +275,22 @@ bool load_from_infofile(const char* file, Assets_t* assets) { if (add_sound(assets, name, info_str) == NULL) { - printf("Unable to add texture at line %lu\n", line_num); + printf("Unable to add sound at line %lu\n", line_num); break; } printf("Added sound %s as %s\n", info_str, name); } break; + case FONT_INFO: + { + if (add_font(assets, name, info_str) == NULL) + { + printf("Unable to add font at line %lu\n", line_num); + break; + } + printf("Added font %s as %s\n", info_str, name); + } + break; case LEVELPACK_INFO: { //if (add_level_pack(assets, name, info_str) == NULL) diff --git a/scenes/menu_scene.c b/scenes/menu_scene.c index 64ebfe8..9624ce6 100644 --- a/scenes/menu_scene.c +++ b/scenes/menu_scene.c @@ -11,12 +11,17 @@ static void menu_scene_render_func(Scene_t* scene) Sprite_t* title_spr = get_sprite(&scene->engine->assets, "title_board"); Sprite_t* title_select = get_sprite(&scene->engine->assets, "title_select"); Rectangle render_rec = scene->layers.render_layers[0].render_area; + Font* menu_font = get_font(&scene->engine->assets, "MenuFont"); BeginTextureMode(scene->layers.render_layers[0].layer_tex); ClearBackground(RAYWHITE); draw_sprite(spr, 0, (Vector2){0, 0}, 0, false); draw_sprite(title_spr, 0, (Vector2){32, 10}, 0, false); - int title_width = MeasureText("Bunny's Spelunking Adventure", 32); - DrawText("Bunny's Spelunking Adventure", (render_rec.width - title_width) / 2, 20, 32, BLACK); + Vector2 title_sz = MeasureTextEx(*menu_font, "Bunny's Spelunking Adventure", 56, 0); + Vector2 title_pos = { + .x = (render_rec.width - title_sz.x) / 2, + .y = 32 + (title_spr->frame_size.y - title_sz.y) / 2 + }; + DrawTextEx(*menu_font, "Bunny's Spelunking Adventure", title_pos, 56, 0, BLACK); const char* OPTIONS[3] = {"Start", "Credits", "Exit"}; for (uint8_t i = 0; i < 3; ++i)