diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-20 18:25:17 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-20 18:25:17 +0100 |
commit | 658997a30b6324fcf5b517b78148958b4a1e0e66 (patch) | |
tree | 1dcffd115bd44282e43f0f8cbbe0ff14f24895de /src | |
parent | Bounce it (diff) | |
download | 42-cub3d-658997a30b6324fcf5b517b78148958b4a1e0e66.tar.gz 42-cub3d-658997a30b6324fcf5b517b78148958b4a1e0e66.tar.bz2 42-cub3d-658997a30b6324fcf5b517b78148958b4a1e0e66.tar.xz 42-cub3d-658997a30b6324fcf5b517b78148958b4a1e0e66.tar.zst 42-cub3d-658997a30b6324fcf5b517b78148958b4a1e0e66.zip |
it's not working at all
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_draw_hud.c | 4 | ||||
-rw-r--r-- | src/ft_draw_life_bar.c | 26 | ||||
-rw-r--r-- | src/ft_tex_init.c | 62 |
3 files changed, 61 insertions, 31 deletions
diff --git a/src/ft_draw_hud.c b/src/ft_draw_hud.c index e852ec1..5feab32 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 + (28 * cl->mlist.scale))) + * cl->mlist.scale) + 20 + (32 * 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 + (28 * scl)) + while (x < (map_w * scl) + 20 + (32 * scl)) { while (y < wl->y_size) y++; diff --git a/src/ft_draw_life_bar.c b/src/ft_draw_life_bar.c index b90daa1..687e3a7 100644 --- a/src/ft_draw_life_bar.c +++ b/src/ft_draw_life_bar.c @@ -15,17 +15,17 @@ #include <stdint.h> static void - ft_draw_tnum(t_img num, int16_t y, int16_t x, t_cub *cl) + ft_draw_tnum(int8_t id, 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); + (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) + 1) = - (uint8_t)*(num.ptr + num.tex_x * 4 + 4 * - num.img_w * num.tex_y + 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) + 2) = - (uint8_t)*(num.ptr + num.tex_x * 4 + 4 * - num.img_w * num.tex_y + 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); } /* static void */ @@ -41,22 +41,22 @@ static void int16_t x; int16_t y; - x_ratio = (int)((cl->tnum[10].img_w << 16) / (7 * cl->mlist.scale)) + 1; + x_ratio = (int)((cl->tnum[10].img_w << 16) / (8 * cl->mlist.scale)) + 1; y_ratio = (int)((cl->tnum[10].img_h << 16) / - ((cl->mlist.map_h * cl->mlist.scale) - 20)) + 1; + ((cl->mlist.map_h * cl->mlist.scale))) + 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))); + x = ((cl->mlist.map_w * cl->mlist.scale) + 20 + ((32 * cl->mlist.scale) + - ((32 * cl->mlist.scale) / 4))); while (x < (int16_t)((cl->mlist.map_w * cl->mlist.scale) - + 10 + ((28 * cl->mlist.scale)))) + + 10 + ((32 * 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); + ft_draw_tnum(10, y, x, cl); x++; } y++; diff --git a/src/ft_tex_init.c b/src/ft_tex_init.c index 5c0bed3..5e445ce 100644 --- a/src/ft_tex_init.c +++ b/src/ft_tex_init.c @@ -41,12 +41,52 @@ */ static void - ft_init_number(t_img *tnum, const char *path, t_cub *cl) + ft_init_numbers(t_cub *cl) { - tnum->img = mlx_xpm_file_to_image(cl->wlist.wlx, - path, &tnum->img_w, &tnum->img_h); - tnum->ptr = mlx_get_data_addr(tnum->img, - &tnum->bpp, &tnum->sizeline, &tnum->endian); + cl->tnum[0].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_ZER_PATH, &cl->tnum[0].img_w, &cl->tnum[0].img_h); + cl->tnum[0].ptr = mlx_get_data_addr(cl->tnum[0].img, + &cl->tnum[0].bpp, &cl->tnum[0].sizeline, &cl->tnum[0].endian); + cl->tnum[1].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_ONE_PATH, &cl->tnum[1].img_w, &cl->tnum[1].img_h); + cl->tnum[1].ptr = mlx_get_data_addr(cl->tnum[1].img, + &cl->tnum[1].bpp, &cl->tnum[1].sizeline, &cl->tnum[1].endian); + cl->tnum[2].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_TWO_PATH, &cl->tnum[2].img_w, &cl->tnum[2].img_h); + cl->tnum[2].ptr = mlx_get_data_addr(cl->tnum[2].img, + &cl->tnum[2].bpp, &cl->tnum[2].sizeline, &cl->tnum[2].endian); + cl->tnum[3].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_THR_PATH, &cl->tnum[3].img_w, &cl->tnum[3].img_h); + cl->tnum[3].ptr = mlx_get_data_addr(cl->tnum[3].img, + &cl->tnum[3].bpp, &cl->tnum[3].sizeline, &cl->tnum[3].endian); + cl->tnum[4].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_FOU_PATH, &cl->tnum[4].img_w, &cl->tnum[4].img_h); + cl->tnum[4].ptr = mlx_get_data_addr(cl->tnum[4].img, + &cl->tnum[4].bpp, &cl->tnum[4].sizeline, &cl->tnum[4].endian); + cl->tnum[5].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_FIV_PATH, &cl->tnum[5].img_w, &cl->tnum[5].img_h); + cl->tnum[5].ptr = mlx_get_data_addr(cl->tnum[5].img, + &cl->tnum[5].bpp, &cl->tnum[5].sizeline, &cl->tnum[5].endian); + cl->tnum[6].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_SIX_PATH, &cl->tnum[6].img_w, &cl->tnum[6].img_h); + cl->tnum[6].ptr = mlx_get_data_addr(cl->tnum[6].img, + &cl->tnum[6].bpp, &cl->tnum[6].sizeline, &cl->tnum[6].endian); + cl->tnum[7].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_SEV_PATH, &cl->tnum[7].img_w, &cl->tnum[7].img_h); + cl->tnum[7].ptr = mlx_get_data_addr(cl->tnum[7].img, + &cl->tnum[7].bpp, &cl->tnum[7].sizeline, &cl->tnum[7].endian); + cl->tnum[8].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_EIG_PATH, &cl->tnum[8].img_w, &cl->tnum[8].img_h); + cl->tnum[8].ptr = mlx_get_data_addr(cl->tnum[8].img, + &cl->tnum[8].bpp, &cl->tnum[8].sizeline, &cl->tnum[8].endian); + cl->tnum[9].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_NIN_PATH, &cl->tnum[9].img_w, &cl->tnum[9].img_h); + cl->tnum[9].ptr = mlx_get_data_addr(cl->tnum[9].img, + &cl->tnum[9].bpp, &cl->tnum[9].sizeline, &cl->tnum[9].endian); + cl->tnum[10].img = mlx_xpm_file_to_image(cl->wlist.wlx, + FT_PER_PATH, &cl->tnum[10].img_w, &cl->tnum[10].img_h); + cl->tnum[10].ptr = mlx_get_data_addr(cl->tnum[10].img, + &cl->tnum[10].bpp, &cl->tnum[10].sizeline, &cl->tnum[10].endian); } static void @@ -96,17 +136,7 @@ static void FT_WEAPON_TWO_SPR_PATH, &cl->tlist[19].img_w, &cl->tlist[19].img_h); cl->tlist[19].ptr = mlx_get_data_addr(cl->tlist[19].img, &cl->tlist[19].bpp, &cl->tlist[19].sizeline, &cl->tlist[19].endian); - ft_init_number(&cl->tnum[0], FT_ZER_PATH, cl); - ft_init_number(&cl->tnum[1], FT_ONE_PATH, cl); - ft_init_number(&cl->tnum[2], FT_TWO_PATH, cl); - ft_init_number(&cl->tnum[3], FT_THR_PATH, cl); - ft_init_number(&cl->tnum[4], FT_FOU_PATH, cl); - ft_init_number(&cl->tnum[5], FT_FIV_PATH, cl); - ft_init_number(&cl->tnum[6], FT_SIX_PATH, cl); - ft_init_number(&cl->tnum[7], FT_SEV_PATH, cl); - ft_init_number(&cl->tnum[8], FT_EIG_PATH, cl); - ft_init_number(&cl->tnum[9], FT_NIN_PATH, cl); - ft_init_number(&cl->tnum[10], FT_PER_PATH, cl); + ft_init_numbers(cl); cl->walltexgood = 1; if (cl->mlist.sprite_var > 1) ft_next_sprite_init(cl); |