|
|
|
@ -500,7 +500,8 @@ void draw_environment(SDL_Renderer * ren, struct environment *scene) {
@@ -500,7 +500,8 @@ void draw_environment(SDL_Renderer * ren, struct environment *scene) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void draw_level_time(SDL_Renderer *ren, struct environment * e) { |
|
|
|
|
void draw_text(SDL_Renderer *rend, Vect pos, struct colour colour, char *text) { |
|
|
|
|
static SDL_Renderer *ren = NULL; |
|
|
|
|
static TTF_Font* font = NULL; |
|
|
|
|
if (!font) { |
|
|
|
|
font = TTF_OpenFont("TerminusTTF.ttf", 18); |
|
|
|
@ -509,20 +510,15 @@ void draw_level_time(SDL_Renderer *ren, struct environment * e) {
@@ -509,20 +510,15 @@ void draw_level_time(SDL_Renderer *ren, struct environment * e) {
|
|
|
|
|
printf("%s\n", err); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int margin = height / 10; |
|
|
|
|
SDL_Rect position = {.x = margin, .y = height - margin}; |
|
|
|
|
struct colour colour = e->colours.fg1; |
|
|
|
|
|
|
|
|
|
int minutes = level_time / 60000; |
|
|
|
|
float seconds = level_time * 0.001; |
|
|
|
|
char time_string[250]; |
|
|
|
|
snprintf(time_string, 250, "%d:%.4f", minutes, seconds); |
|
|
|
|
if (!ren) { |
|
|
|
|
ren = rend; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SDL_Colour sdl_col = {colour.r, colour.g, colour.b, 255};
|
|
|
|
|
SDL_Rect position = {.x = pos.x, .y = pos.y}; |
|
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(ren, colour.r, colour.g, colour.b, 255); |
|
|
|
|
SDL_Surface *surf = TTF_RenderText_Solid(font, time_string, sdl_col); |
|
|
|
|
SDL_Surface *surf = TTF_RenderText_Solid(font, text, sdl_col); |
|
|
|
|
|
|
|
|
|
SDL_Texture *texture = SDL_CreateTextureFromSurface(ren, surf); |
|
|
|
|
SDL_QueryTexture(texture, NULL, NULL, &position.w, &position.h); |
|
|
|
@ -533,6 +529,22 @@ void draw_level_time(SDL_Renderer *ren, struct environment * e) {
@@ -533,6 +529,22 @@ void draw_level_time(SDL_Renderer *ren, struct environment * e) {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void draw_level_time(SDL_Renderer *ren, struct environment * e) { |
|
|
|
|
|
|
|
|
|
int margin = height / 10; |
|
|
|
|
Vect position = {.x = margin, .y = height - margin}; |
|
|
|
|
|
|
|
|
|
struct colour colour = e->colours.fg1; |
|
|
|
|
|
|
|
|
|
int minutes = level_time / 60000; |
|
|
|
|
float seconds = level_time * 0.001; |
|
|
|
|
char time_string[250]; |
|
|
|
|
snprintf(time_string, 250, "%d:%.4f", minutes, seconds); |
|
|
|
|
|
|
|
|
|
draw_text(ren, position, colour, time_string); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void redraw_buffer(SDL_Renderer * ren) { |
|
|
|
|
static int mousex = 0; |
|
|
|
|
static int mousey = 0; |
|
|
|
|