From 3cccc0451cbe991f837a1527883701e86f96109b Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sat, 21 Mar 2020 18:07:13 +0100 Subject: Great --- src/ft_draw_life_bar.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/ft_draw_life_bar.c b/src/ft_draw_life_bar.c index f429b43..c8cf629 100644 --- a/src/ft_draw_life_bar.c +++ b/src/ft_draw_life_bar.c @@ -33,28 +33,8 @@ static void cl->tnum[id].img_w * cl->tnum[id].tex_y + 2]; } -/* static void */ -/* ft_put_next_number(char n, int16_t x_offset, t_cub *cl); */ - -/* static void */ -/* ft_put_image_from_number(char *num, uint16_t h, uint16_t w, t_cub *cl) */ -/* { */ -/* const size_t len = ft_strlen(num); */ - -/* (void)num; */ -/* (void)h; */ -/* (void)w; */ -/* (void)cl; */ -/* if (len == 3) */ -/* { */ -/* ft_put_next_number(num[0], 0, cl); */ -/* ft_put_next_number(num[1], 0, cl); */ -/* ft_put_next_number(num[2], 0, cl); */ -/* } */ -/* } */ - static void - ft_put_percent_image(char n, uint16_t x_offset, t_cub *cl) + ft_put_next_number(char n, uint16_t x_offset, t_cub *cl) { int32_t x_ratio; int32_t y_ratio; @@ -81,6 +61,28 @@ static void } } +static void + ft_put_image_from_number(char *num, t_cub *cl) +{ + const size_t len = ft_strlen(num); + const int16_t scl = cl->mlist.scale; + + (void)cl; + if (len == 3) + { + ft_put_next_number(num[0], 0, cl); + ft_put_next_number(num[1], (1 * (32 * scl) / 4), cl); + ft_put_next_number(num[2], (2 * (32 * scl) / 4), cl); + } + else if (len == 2) + { + ft_put_next_number(num[0], (1 * (32 * scl) / 4), cl); + ft_put_next_number(num[1], (2 * (32 * scl) / 4), cl); + } + else + ft_put_next_number(num[0], (2 * (32 * scl) / 4), cl); +} + static void ft_get_hw(t_cub *cl) { @@ -113,7 +115,7 @@ void if (!(num = ft_itoa((int64_t)calc))) ft_error(FT_RET_ALLOC_ERR, FT_ERR_ALLOCATE, cl); ft_get_hw(cl); - ft_put_percent_image(58, (3 * (32 * scl) / 4), cl); - /* ft_put_image_from_number(num, y, x, 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