simplify code

This commit is contained in:
KikooDX 2021-05-05 15:56:14 +02:00
parent d9620de106
commit d6461931ad
1 changed files with 6 additions and 7 deletions

View File

@ -18,7 +18,8 @@ void check_medal(unsigned int frame_level, int id_level, int x, int y)
* generated code had. But the conditions were so dirty and hard to
* understand than I simplified it.
* -- KikooDX */
for (i = 0; i < 4; i += 1) {
i = 4;
while (i-- > 0) {
const int mtime = (int)(time * medal_multiplier[i] * 100.0);
if (player_time <= mtime) {
dsubimage(x + 15 * (3 - i), y, &img_medals,
@ -30,16 +31,14 @@ void check_medal(unsigned int frame_level, int id_level, int x, int y)
void draw_time(int id_level)
{
const float time = level_time[id_level - 1];
int draw_y = 140;
int medal_x = 36;
int i;
for (i = 0; i < 4; i += 1) {
dsubimage(340, draw_y, &img_medals, medal_x, 0, 12, 12,
i = 4;
while (i-- > 0) {
const int draw_y = 140 + 20 * i;
dsubimage(340, draw_y, &img_medals, 12 * (3 - i), 0, 12, 12,
DIMAGE_NONE);
dprint(355, draw_y + 1, C_BLACK, "%.2j",
(int)(time * medal_multiplier[i] * 100));
draw_y += 20;
medal_x -= 12;
}
}