From 7deb7b9123b359d203a9a62f56c88bd6c05edf33 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sat, 21 Mar 2020 19:11:44 +0100 Subject: I can't believe it worked --- src/ft_draw_life_bar.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/ft_draw_life_bar.c') diff --git a/src/ft_draw_life_bar.c b/src/ft_draw_life_bar.c index c81e550..85db1ec 100644 --- a/src/ft_draw_life_bar.c +++ b/src/ft_draw_life_bar.c @@ -19,15 +19,18 @@ static void { const int16_t scl = cl->mlist.scale; - cl->img.ptr[x * 4 + (cl->img.sizeline * (y + + cl->img.ptr[(x + (int16_t)((cl->mlist.map_w * scl) + + 10 + ((32 * scl) / 4))) * 4 + (cl->img.sizeline * (y + cl->wlist.y_size - (cl->mlist.map_h * scl) - 10))] = (uint8_t)cl->tnum[id].ptr[cl->tnum[id].tex_x * 4 + 4 * cl->tnum[id].img_w * cl->tnum[id].tex_y]; - cl->img.ptr[x * 4 + (cl->img.sizeline * (y + + cl->img.ptr[(x + (int16_t)((cl->mlist.map_w * scl) + + 10 + ((32 * scl) / 4))) * 4 + (cl->img.sizeline * (y + cl->wlist.y_size - (cl->mlist.map_h * scl) - 10)) + 1] = (uint8_t)cl->tnum[id].ptr[cl->tnum[id].tex_x * 4 + 4 * cl->tnum[id].img_w * cl->tnum[id].tex_y + 1]; - cl->img.ptr[x * 4 + (cl->img.sizeline * (y + + cl->img.ptr[(x + (int16_t)((cl->mlist.map_w * scl) + + 10 + ((32 * scl) / 4))) * 4 + (cl->img.sizeline * (y + cl->wlist.y_size - (cl->mlist.map_h * scl) - 10)) + 2] = (uint8_t)cl->tnum[id].ptr[cl->tnum[id].tex_x * 4 + 4 * cl->tnum[id].img_w * cl->tnum[id].tex_y + 2]; @@ -40,7 +43,7 @@ static void int32_t y_ratio; int16_t x; int16_t y; - const int16_t scl = cl->mlist.scale; + /* const int16_t scl = cl->mlist.scale; */ x_ratio = (int)(((cl->tnum[n - 48].img_w) << 16) / cl->w) + 1; y_ratio = (int)(((cl->tnum[n - 48].img_h) << 16) / cl->h) + 1; @@ -48,14 +51,16 @@ static void while (y < cl->h) { cl->tnum[n - 48].tex_y = ((y * y_ratio) >> 16); - x = ((cl->mlist.map_w * scl) + 20) + x_offset; - while (x < (int16_t)((cl->mlist.map_w * scl) - + 10 + ((32 * scl) / 4) + x_offset)) + /* x = ((cl->mlist.map_w * scl) + 20); */ + x = 0; + /* while (x < (int16_t)((cl->mlist.map_w * scl) */ + /* + 10 + ((32 * scl) / 4))) */ + while (x < cl->w) { cl->tnum[n - 48].tex_x = ((x * x_ratio) >> 16); if (cl->tnum[n - 48].ptr[cl->tnum[n - 48].tex_x * 4 + 4 * cl->tnum[n - 48].img_h * cl->tnum[n - 48].tex_y]) - ft_draw_tnum(n - 48, y, x, cl); + ft_draw_tnum(n - 48, y, x + x_offset, cl); x++; } y++; @@ -108,15 +113,13 @@ static void void ft_draw_life_bar(t_cub *cl) { - char *num; + char num[4]; float calc; const int16_t scl = cl->mlist.scale; calc = ((float)cl->plist.life / (float)FT_STRT_LIFE) * 100.0; - if (!(num = ft_itoa((int64_t)calc))) - ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, cl); + ft_sprintf(num, "%hd", (int16_t)calc); ft_get_hw(cl); ft_put_next_number(58, (3 * (32 * scl) / 4), cl); ft_put_image_from_number(num, cl); - ft_memdel((void*)&num); } -- cgit v1.2.3