From bf2cce96c3c5657946070a07b8dcda5dad199481 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sun, 23 Feb 2020 16:30:47 +0100 Subject: Trying life bars --- Makefile | 1 + inc/cub3d.h | 2 ++ inc/cub3d_structs.h | 1 + src/ft_draw_hud.c | 6 ++++-- src/ft_init_lists.c | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4c10947..1af8b6a 100644 --- a/Makefile +++ b/Makefile @@ -60,6 +60,7 @@ SRCS_NAME += ft_key_release.c SRCS_NAME += ft_convert_keycode.c SRCS_NAME += ft_key_loop.c SRCS_NAME += ft_draw_hud.c +SRCS_NAME += ft_draw_life_bar.c #--------------------------------------------------------------------------------------------------# SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME}) #--------------------------------------------------------------------------------------------------# diff --git a/inc/cub3d.h b/inc/cub3d.h index 7ebf492..e8e3249 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -85,5 +85,7 @@ void ft_draw_texture(t_cub *cl, int x, int y, int tex_y); int8_t ft_check_not_found(const char *path); void ft_calc_tex(t_cub *clist); void ft_draw_hud(t_cub *clist); +void ft_draw_life_bar(size_t map_w, uint16_t scale, + int8_t life, t_cub *cl); # endif diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h index 639de11..b185d92 100644 --- a/inc/cub3d_structs.h +++ b/inc/cub3d_structs.h @@ -67,6 +67,7 @@ typedef struct s_player float cam_x; float plane_x; float plane_y; + int8_t life; } t_player; typedef struct s_ray diff --git a/src/ft_draw_hud.c b/src/ft_draw_hud.c index 46662fa..038d1f2 100644 --- a/src/ft_draw_hud.c +++ b/src/ft_draw_hud.c @@ -61,7 +61,7 @@ static void *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = col; if (!(y % 3)) { - if (col < 0x00AAAAAA) + if (col < 0x00aaaaaa) col += 0x00010101; } y++; @@ -90,7 +90,7 @@ static void *(int*)(cl->img.ptr + (x * 4 + (y * cl->img.sizeline))) = col; if (!(y % 2)) { - if (col < 0x00AAAAAA) + if (col < 0x00aaaaaa) col += 0x00010101; } y++; @@ -110,4 +110,6 @@ void ft_draw_hud_back_top_r(clist->mlist->map_h, clist->mlist->map_w, clist->wlist, clist); ft_draw_map(clist->mlist->map, clist); + ft_draw_life_bar(clist->mlist->map_w, clist->mlist->scale, + clist->plist->life, clist); } diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index 5592358..b9dbfd3 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -45,6 +45,7 @@ static t_player plist->dir_y = 0; plist->plane_x = 0; plist->plane_y = 0.66666666; + plist->life = 100; return (plist); } -- cgit v1.2.3