thrive/01_text_adventure/intro.c

41 lines
1.0 KiB
C
Raw Normal View History

2025-01-24 18:22:26 -05:00
#include <stdlib.h>
#include "intro.h"
#define FONT_SIZE 36
void display_loading(void) {
int window_width = GetRenderWidth();
int window_height = GetRenderHeight();
int loading_width = MeasureText("Loading...", FONT_SIZE);
BeginDrawing();
DrawText("Loading...", window_width - loading_width, window_height - FONT_SIZE, FONT_SIZE, RAYWHITE);
EndDrawing();
}
Intro *load_intro(void) {
Intro *i = malloc(sizeof(Intro));
i->textures = malloc(sizeof(Texture) * 2);
Image bgb = LoadImage("img/made_by_bgb.png");
i->textures[0] = LoadTextureFromImage(bgb);
UnloadImage(bgb);
Image ray = LoadImage("img/made_w_raylib.png");
i->textures[1] = LoadTextureFromImage(ray);
UnloadImage(ray);
i->texture_count = 2;
i->timer = 0.;
return i;
}
void intro_display(Intro *intro) {
for (int i = 0; i < intro->texture_count; i++) {
intro->timer = GetTime() + 2.0;
BeginDrawing();
DrawTexture(intro->textures[i], 0, 0, WHITE);
EndDrawing();
while(GetTime() < intro->timer) {}
}
}