diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ft_drawsquare.c | 22 | ||||
-rw-r--r-- | src/ft_exit.c | 12 | ||||
-rw-r--r-- | src/ft_init_lists.c | 16 | ||||
-rw-r--r-- | src/ft_key_events.c | 17 | ||||
-rw-r--r-- | src/ft_parse_map.c | 2 | ||||
-rw-r--r-- | src/main.c | 12 |
6 files changed, 56 insertions, 25 deletions
diff --git a/src/ft_drawsquare.c b/src/ft_drawsquare.c new file mode 100644 index 0000000..d720f44 --- /dev/null +++ b/src/ft_drawsquare.c @@ -0,0 +1,22 @@ +#include <mlx.h> +#include <cub3d.h> + +void +ft_drawsquare(t_win *wlist, int a, int b) +{ + int x; + int y; + + x = a; + y = b; + while (x > a - 40) + { + while (y > b - 40) + { + mlx_pixel_put(wlist->wlx, wlist->winptr, x, y, 255); + y--; + } + y = b; + x--; + } +} diff --git a/src/ft_exit.c b/src/ft_exit.c new file mode 100644 index 0000000..a5b7276 --- /dev/null +++ b/src/ft_exit.c @@ -0,0 +1,12 @@ +#include <libft.h> +#include <stdlib.h> +#include <inttypes.h> + +void +ft_exit(uint8_t exit_code) +{ + ft_printf("Exiting program\n"); + if (exit_code < 0 || exit_code > 0) + ft_printf("Exit code: %hhu\n", exit_code); + exit(exit_code); +} diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c index b6f2932..7a6eb79 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -3,12 +3,12 @@ #include <cub3d.h> #include <stdlib.h> -t_winlist -*ft_init_winlist(void) +t_win +*ft_init_win(void) { - t_winlist *wlist; + t_win *wlist; - wlist = (t_winlist*)malloc(sizeof(t_winlist)); + wlist = (t_win*)malloc(sizeof(t_win)); wlist->x_size = 800; wlist->y_size = 600; wlist->wlx = mlx_init(); @@ -18,11 +18,11 @@ t_winlist return (wlist); } -t_cublist -*ft_init_cublist(void) +t_cub +*ft_init_cub(void) { - t_cublist *clist; + t_cub *clist; - clist = (t_cublist*)malloc(sizeof(t_cublist)); + clist = (t_cub*)malloc(sizeof(t_cub)); return (clist); } diff --git a/src/ft_key_events.c b/src/ft_key_events.c index 82235fc..6702988 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -5,28 +5,28 @@ static int ft_w_key(void) { - ft_printf("w\n"); + ft_printf("[W]\n"); return (0); } static int ft_a_key(void) { - ft_printf("a\n"); + ft_printf("[A]\n"); return (0); } static int ft_s_key(void) { - ft_printf("s\n"); + ft_printf("[S]\n"); return (0); } static int ft_d_key(void) { - ft_printf("d\n"); + ft_printf("[D]\n"); return (0); } @@ -44,11 +44,10 @@ ft_key_event(int keycode, void *param) (keycode <= 3) ? ((*fun_ptr[keycode])()) : 0; if (keycode == 53) { - ft_memdel(((t_winlist*)param)->wlx); - ft_memdel(((t_winlist*)param)->winptr); - ft_memdel((t_winlist*)param); - ft_printf("Exiting program\n"); - exit(0); + ft_memdel(((t_win*)param)->wlx); + ft_memdel(((t_win*)param)->winptr); + ft_memdel((t_win*)param); + ft_exit(0); } return (0); } diff --git a/src/ft_parse_map.c b/src/ft_parse_map.c index b600849..baf3b5f 100644 --- a/src/ft_parse_map.c +++ b/src/ft_parse_map.c @@ -3,6 +3,6 @@ #include <stdlib.h> void -ft_parse_map(t_cublist *clist) +ft_parse_map(t_cub *clist) { } @@ -6,16 +6,14 @@ int main(void) { - t_winlist *wlist; - t_cublist *clist; + t_win *wlist; + t_cub *clist; - wlist = ft_init_winlist(); - clist = ft_init_cublist(); + wlist = ft_init_win(); + clist = ft_init_cub(); mlx_key_hook(wlist->winptr, ft_key_event, wlist); + ft_drawsquare(wlist, 80, 80); mlx_loop(wlist->wlx); - ft_memdel(wlist->wlx); - ft_memdel(wlist->winptr); - ft_memdel(wlist); ft_memdel(clist); return (0); } |