diff options
-rw-r--r-- | src/ft_draw_life_bar.c | 27 | ||||
-rw-r--r-- | src/ft_set_minimap_scale.c | 8 | ||||
-rw-r--r-- | src/ft_warp_level.c | 2 |
3 files changed, 19 insertions, 18 deletions
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); } diff --git a/src/ft_set_minimap_scale.c b/src/ft_set_minimap_scale.c index 14a6f56..fcda6f6 100644 --- a/src/ft_set_minimap_scale.c +++ b/src/ft_set_minimap_scale.c @@ -12,6 +12,7 @@ #include <cub3d.h> +#include <libft.h> void ft_set_minimap_scale(t_cub *clist) { @@ -21,16 +22,15 @@ void if (ml->map_w > ml->map_h) { ml->scale = (clist->wlist.x_size / (uint16_t)ml->map_w); - ml->scale = ((ml->scale - 1) < 1) ? (1) : (ml->scale); - ml->scale = (clist->wlist.y_size < (ml->map_h * ml->scale)) - ? ((clist->wlist.y_size / (uint16_t)ml->map_h) - 1) : (ml->scale); + ml->scale = (clist->wlist.x_size < (ml->map_w * ml->scale)) + ? ((clist->wlist.x_size / (uint16_t)ml->map_w) - 1) : (ml->scale); } else { ml->scale = (clist->wlist.y_size / (uint16_t)ml->map_h); - ml->scale = ((ml->scale - 1) < 1) ? (1) : (ml->scale); ml->scale = (clist->wlist.y_size < (ml->map_h * ml->scale)) ? ((clist->wlist.y_size / (uint16_t)ml->map_h) - 1) : (ml->scale); } + ml->scale = ((ml->scale - 1) < 1) ? (1) : (ml->scale); ml->scale = (ml->scale >= 10) ? (ml->scale / 4) : (ml->scale); } diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c index af05b29..93c47a4 100644 --- a/src/ft_warp_level.c +++ b/src/ft_warp_level.c @@ -135,7 +135,6 @@ int8_t char *tmp_mup; uint8_t isoldmus; - ft_printf("%hd\n", cl->plist.life); if (!(next_path = (char *)malloc((ft_strlen(path) + 1) * sizeof(char)))) return (-1); ft_sprintf(next_path, "%s", path); @@ -155,6 +154,5 @@ int8_t ft_wall_tex_init(cl); ft_weap_tex_init(cl); ft_memdel((void*)&next_path); - ft_printf("%hd\n", cl->plist.life); return (0); } |