player rotates and moves, rays for raycasting on map

This commit is contained in:
Hugo LAMY
2022-04-18 18:27:16 +02:00
parent 00b3612c16
commit 01eb2255d2
21 changed files with 689 additions and 138 deletions

View File

@@ -1,16 +1,13 @@
#include "cube3d.h"
t_exit **mb_exit_func();
t_list **mb_lst();
int mb_comp_addr(void *to_find, void *to_compare);
void mb_set_params_exit(void (*f)(void *), void *param);
void mb_exec_exit_func();
t_list **mb_get_lst(void);
int mb_comp_addr(void *to_find, void *to_compare);
void mb_init(void(*f)(void*), void *param)
void mb_init(void (*f)(void *), void *param)
{
t_exit **texit;
texit = mb_exit_func();
(*texit)->param = param;
(*texit)->f = f;
mb_set_params_exit(f, param);
}
void *mb_alloc(size_t size)
@@ -18,7 +15,7 @@ void *mb_alloc(size_t size)
void *tmp;
t_list **lst;
lst = mb_lst();
lst = mb_get_lst();
tmp = ft_memalloc(size);
if (!tmp)
mb_exit(B_RED"failed create new allocation"RESET"\n");
@@ -31,7 +28,7 @@ void mb_add(void *addr)
{
t_list **lst;
lst = mb_lst();
lst = mb_get_lst();
if (!ft_lstpush_back(lst, ft_lstcreate(addr)))
mb_exit(B_RED"failed add new element to list"RESET"\n");
}
@@ -41,22 +38,19 @@ void mb_free(void *addr)
t_list **lst;
t_list *tmp;
lst = mb_lst();
lst = mb_get_lst();
tmp = ft_lstfind((*lst), addr, mb_comp_addr);
if (!tmp)
ft_putstr_fd(B_RED"element to free doesn't exist (maybe it was already freed)"RESET"\n", 2);
ft_putstr_fd(B_RED"you try to free not allocated address"RESET"\n", 2);
ft_lsterase(tmp, free);
}
void mb_exit(char *str)
{
t_list **lst;
t_exit **texit;
lst = mb_lst();
texit = mb_exit_func();
if ((*texit)->f)
(*texit)->f((*texit)->param);
lst = mb_get_lst();
mb_exec_exit_func();
ft_putstr_fd(str, 2);
ft_lstfree((*lst), free);
exit(0);