|
|
@ -535,22 +535,71 @@ int draw_end_screen(SDL_Renderer *ren) { |
|
|
|
int margin = height / 10; |
|
|
|
int margin = height / 10; |
|
|
|
// Vect position = {.x = width - width / 10, .y = height - margin};
|
|
|
|
// Vect position = {.x = width - width / 10, .y = height - margin};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long fastest = get_best_time(); |
|
|
|
|
|
|
|
|
|
|
|
int minutes = level_time / 60000; |
|
|
|
int minutes = level_time / 60000; |
|
|
|
float seconds = level_time * 0.001; |
|
|
|
float seconds = level_time * 0.001; |
|
|
|
char time_string[250]; |
|
|
|
char time_string[250]; |
|
|
|
snprintf(time_string, 250, "TIME: %d:%.4f", minutes, seconds); |
|
|
|
|
|
|
|
char * end_str = "Level over."; |
|
|
|
|
|
|
|
char * ct_str = "Press any key to continue."; |
|
|
|
|
|
|
|
char qual_str[250]; |
|
|
|
char * end_str = "level over."; |
|
|
|
snprintf(qual_str, 250, "Physics quality: %d", quality); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vect position = {.x = width/3, .y = height / 4}; |
|
|
|
Vect position = {.x = width/3, .y = height / 4}; |
|
|
|
draw_text(ren, position, colour, end_str); |
|
|
|
draw_text(ren, position, colour, end_str); |
|
|
|
position.y += 40; |
|
|
|
position.y += 40; |
|
|
|
draw_text(ren, position, colour, time_string); |
|
|
|
|
|
|
|
|
|
|
|
char level_string[250]; |
|
|
|
|
|
|
|
snprintf(level_string, 250,"course: %d", level); |
|
|
|
|
|
|
|
draw_text(ren, position, colour, level_string); |
|
|
|
position.y += 40; |
|
|
|
position.y += 40; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char qual_str[250]; |
|
|
|
|
|
|
|
snprintf(qual_str, 250, "physics quality: %d", quality); |
|
|
|
draw_text(ren, position, colour, qual_str); |
|
|
|
draw_text(ren, position, colour, qual_str); |
|
|
|
position.y += 40; |
|
|
|
position.y += 40; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char fastest_time[250]; |
|
|
|
|
|
|
|
minutes = fastest / 60000; |
|
|
|
|
|
|
|
seconds = fastest * 0.001; |
|
|
|
|
|
|
|
if (fastest > 0) { |
|
|
|
|
|
|
|
position.y += 40; |
|
|
|
|
|
|
|
snprintf(fastest_time, 250, "old best time: %d:%.4f", minutes, seconds); |
|
|
|
|
|
|
|
draw_text(ren, position, colour, fastest_time); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
minutes = level_time / 60000; |
|
|
|
|
|
|
|
seconds = level_time * 0.001; |
|
|
|
|
|
|
|
if (level_time > fastest) { |
|
|
|
|
|
|
|
// base time not set yet.
|
|
|
|
|
|
|
|
snprintf(time_string, 250, "TIME: %d:%.4f", minutes, seconds); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
snprintf(time_string, 250, "NEW BEST TIME: %d:%.4f", minutes, seconds); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vect position2 = {.x = 3 * width/5, .y = 40 + height / 4}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fastest > 0) { |
|
|
|
|
|
|
|
//position.y += 40;
|
|
|
|
|
|
|
|
long diff = level_time - fastest; |
|
|
|
|
|
|
|
char diff_str[250]; |
|
|
|
|
|
|
|
minutes = diff / 60000; |
|
|
|
|
|
|
|
seconds = diff * 0.001; |
|
|
|
|
|
|
|
if (minutes > 0) { |
|
|
|
|
|
|
|
snprintf(diff_str, 250, "DIFF: %d:%.4f", minutes, fabs(seconds)); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
snprintf(diff_str, 250, "DIFF: %.4f s", seconds); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
draw_text(ren, position2, colour, diff_str); |
|
|
|
|
|
|
|
position2.y += 40; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
draw_text(ren, position2, colour, time_string); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position.y += 200; |
|
|
|
|
|
|
|
char * ct_str = "press any key to continue"; |
|
|
|
draw_text(ren, position, colour, ct_str); |
|
|
|
draw_text(ren, position, colour, ct_str); |
|
|
|
|
|
|
|
|
|
|
|
SDL_RenderPresent(ren); |
|
|
|
SDL_RenderPresent(ren); |
|
|
@ -561,15 +610,20 @@ int draw_end_screen(SDL_Renderer *ren) { |
|
|
|
void draw_level_time(SDL_Renderer *ren, struct environment * e) { |
|
|
|
void draw_level_time(SDL_Renderer *ren, struct environment * e) { |
|
|
|
|
|
|
|
|
|
|
|
int margin = height / 10; |
|
|
|
int margin = height / 10; |
|
|
|
Vect position = {.x = width - width / 10, .y = height - margin}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct colour colour = e->colours.fg1; |
|
|
|
struct colour colour = e->colours.fg1; |
|
|
|
|
|
|
|
|
|
|
|
int minutes = level_time / 60000; |
|
|
|
int minutes = level_time / 60000; |
|
|
|
float seconds = level_time * 0.001; |
|
|
|
float seconds = level_time * 0.001; |
|
|
|
char time_string[250]; |
|
|
|
char time_string[250]; |
|
|
|
snprintf(time_string, 250, "%d:%.4f", minutes, seconds); |
|
|
|
snprintf(time_string, 250, "time: %d:%.4f", minutes, seconds); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char level_string[250]; |
|
|
|
|
|
|
|
snprintf(level_string, 250,"course: %d", level); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vect position = {.x = margin, .y = height - margin}; |
|
|
|
|
|
|
|
draw_text(ren, position, colour, level_string); |
|
|
|
|
|
|
|
position.y += 40; |
|
|
|
draw_text(ren, position, colour, time_string); |
|
|
|
draw_text(ren, position, colour, time_string); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|