aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h2
-rw-r--r--src/ft_draw_hud.c6
-rw-r--r--src/ft_draw_life_bar.c36
3 files changed, 38 insertions, 6 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index f4dac89..ee2da75 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -93,7 +93,7 @@ void ft_draw_skybox(t_cub *cl);
void ft_draw_handweap(t_cub *cl);
void ft_macos_suffer_animation(t_cub *cl);
void ft_linux_suffer_animation(t_cub *cl);
-void ft_draw_life_bar(t_win *wl, t_cub *cl);
+void ft_draw_life_bar(t_cub *cl);
/*
** ====== PARSING ======
diff --git a/src/ft_draw_hud.c b/src/ft_draw_hud.c
index 31d5021..e852ec1 100644
--- a/src/ft_draw_hud.c
+++ b/src/ft_draw_hud.c
@@ -45,7 +45,7 @@ static void
x = 0;
cl->tlist[16].tex_y = (y * y_ratio) >> 16;
while (x < (uint16_t)((cl->mlist.map_w
- * cl->mlist.scale) + 20 + (27 * cl->mlist.scale)))
+ * cl->mlist.scale) + 20 + (28 * cl->mlist.scale)))
{
cl->tlist[16].tex_x = (x * x_ratio) >> 16;
ft_put_image_back_to_ptr(y, x, cl);
@@ -64,7 +64,7 @@ static void
x = 0;
y = wl->y_size - (map_h * scl) - 20;
- while (x < (map_w * scl) + 20 + (27 * scl))
+ while (x < (map_w * scl) + 20 + (28 * scl))
{
while (y < wl->y_size)
y++;
@@ -107,7 +107,7 @@ int8_t
ft_draw_minimap_back(clist->mlist.map_h,
clist->mlist.map_w, &clist->wlist, clist);
ft_draw_map(clist->mlist.map, clist);
- ft_draw_life_bar(&clist->wlist, clist);
+ ft_draw_life_bar(clist);
if (clist->mlist.isnlvl)
{
ft_draw_stage_back(clist);
diff --git a/src/ft_draw_life_bar.c b/src/ft_draw_life_bar.c
index f9d5227..06ecf70 100644
--- a/src/ft_draw_life_bar.c
+++ b/src/ft_draw_life_bar.c
@@ -14,6 +14,20 @@
#include <cub3d.h>
#include <stdint.h>
+static void
+ ft_draw_tnum(t_img num, int16_t y, int16_t x, t_cub *cl)
+{
+ *(cl->img.ptr + x * 4 + (cl->img.sizeline * y)) =
+ (uint8_t)*(num.ptr + num.tex_x * 4 + 4 *
+ num.img_w * num.tex_y);
+ *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 1) =
+ (uint8_t)*(num.ptr + num.tex_x * 4 + 4 *
+ num.img_w * num.tex_y + 1);
+ *(cl->img.ptr + x * 4 + (cl->img.sizeline * y) + 2) =
+ (uint8_t)*(num.ptr + num.tex_x * 4 + 4 *
+ num.img_w * num.tex_y + 2);
+}
+
/* static void */
/* ft_put_image_from_number(char *num, t_cub *cl) */
/* { */
@@ -24,21 +38,39 @@ static void
{
int32_t x_ratio;
int32_t y_ratio;
+ int16_t x;
+ int16_t y;
x_ratio = (int)((cl->tnum[10].img_w << 16) / (7 * cl->mlist.scale)) + 1;
y_ratio = (int)((cl->tnum[10].img_h << 16) /
((cl->mlist.map_h * cl->mlist.scale) - 20)) + 1;
+ y = cl->wlist.y_size - (cl->mlist.map_h * cl->mlist.scale) + 10;
+ while (y < (int16_t)cl->wlist.y_size - 10)
+ {
+ cl->tnum[10].tex_y = (y * y_ratio) >> 16;
+ x = ((cl->mlist.map_w * cl->mlist.scale) + 20 + ((28 * cl->mlist.scale)
+ - ((28 * cl->mlist.scale) / 4)));
+ while (x < (int16_t)((cl->mlist.map_w * cl->mlist.scale)
+ + 10 + ((28 * cl->mlist.scale))))
+ {
+ cl->tnum[10].tex_x = (x * x_ratio) >> 16;
+ if (cl->tnum[10].ptr[cl->tnum[10].tex_x * 4 + 4 *
+ cl->tnum[10].img_h * cl->tnum[10].tex_y])
+ ft_draw_tnum(cl->tnum[10], y, x, cl);
+ x++;
+ }
+ y++;
+ }
}
void
- ft_draw_life_bar(t_win *wl, t_cub *cl)
+ ft_draw_life_bar(t_cub *cl)
{
char *num;
float calc;
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);
- (void)wl;
ft_put_percent_image(cl);
/* ft_put_image_from_number(num, cl); */
ft_memdel((void*)&num);