2021-05-05 15:46:08 +02:00
|
|
|
#include "define.h"
|
2021-05-05 14:37:12 +02:00
|
|
|
#include "times.h"
|
|
|
|
#include <gint/display.h>
|
|
|
|
|
|
|
|
extern bopti_image_t img_medals;
|
|
|
|
|
|
|
|
extern float level_time[];
|
|
|
|
|
2021-05-05 15:46:08 +02:00
|
|
|
static const float medal_multiplier[4] = {1.0, 1.2, 1.5, 2};
|
|
|
|
|
|
|
|
void check_medal(unsigned int frame_level, int id_level, int x, int y)
|
|
|
|
{
|
|
|
|
const float time = level_time[id_level - 1];
|
|
|
|
const int player_time = (int)((float)frame_level / FPS * 100.0);
|
|
|
|
int i;
|
|
|
|
|
2021-05-05 15:56:14 +02:00
|
|
|
i = 4;
|
|
|
|
while (i-- > 0) {
|
2021-05-05 15:46:08 +02:00
|
|
|
const int mtime = (int)(time * medal_multiplier[i] * 100.0);
|
|
|
|
if (player_time <= mtime) {
|
|
|
|
dsubimage(x + 15 * (3 - i), y, &img_medals,
|
|
|
|
12 * (3 - i), 0, 12, 12, DIMAGE_NONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-05 14:37:12 +02:00
|
|
|
void draw_time(int id_level)
|
|
|
|
{
|
|
|
|
const float time = level_time[id_level - 1];
|
|
|
|
int i;
|
|
|
|
|
2021-05-05 15:56:14 +02:00
|
|
|
i = 4;
|
|
|
|
while (i-- > 0) {
|
|
|
|
const int draw_y = 140 + 20 * i;
|
|
|
|
dsubimage(340, draw_y, &img_medals, 12 * (3 - i), 0, 12, 12,
|
2021-05-05 14:37:12 +02:00
|
|
|
DIMAGE_NONE);
|
|
|
|
dprint(355, draw_y + 1, C_BLACK, "%.2j",
|
|
|
|
(int)(time * medal_multiplier[i] * 100));
|
|
|
|
}
|
|
|
|
}
|