aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--inc/cub3d.h1
-rw-r--r--map/lvl_one.cub2
-rw-r--r--src/ft_exit.c2
-rw-r--r--src/ft_init_lists.c2
-rw-r--r--src/ft_key_loop.c13
-rw-r--r--src/ft_warp_level.c17
6 files changed, 17 insertions, 20 deletions
diff --git a/inc/cub3d.h b/inc/cub3d.h
index a7b649d..e351fa9 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -27,6 +27,7 @@ void ft_init_ref(t_cub *clist);
int8_t ft_init_cub3d(t_cub *clist);
int ft_init_winlx(t_cub *clist);
int ft_init_winptr(t_cub *clist);
+t_player ft_init_player(void);
t_ray ft_init_s_ray(void);
t_rgb ft_init_rgb(void);
int8_t ft_init_map(t_map *mlist);
diff --git a/map/lvl_one.cub b/map/lvl_one.cub
index 2c52287..64c741b 100644
--- a/map/lvl_one.cub
+++ b/map/lvl_one.cub
@@ -1,4 +1,4 @@
-R 1440 1000
+R 800 600
NO ./media/img/BRIQUASSE_3.xpm
SO ./media/img/BRIQUASSE_3.xpm
diff --git a/src/ft_exit.c b/src/ft_exit.c
index 3b00701..4125567 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -62,6 +62,8 @@ static void
mlx_destroy_image(clist->wlist.wlx, clist->tlist[6].img);
if (clist->mlist.isctex && clist->tlist[7].img)
mlx_destroy_image(clist->wlist.wlx, clist->tlist[7].img);
+ if (clist->mlist.istrap && clist->tlist[15].img)
+ mlx_destroy_image(clist->wlist.wlx, clist->tlist[15].img);
}
int
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index bd2ae74..8ba9a13 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -28,7 +28,7 @@ t_rgb
return (rgb);
}
-static t_player
+t_player
ft_init_player(void)
{
t_player plist;
diff --git a/src/ft_key_loop.c b/src/ft_key_loop.c
index d3e871b..c68b228 100644
--- a/src/ft_key_loop.c
+++ b/src/ft_key_loop.c
@@ -26,7 +26,7 @@ static uint64_t
return (pl->pos_x - (pl->dir_y * FT_COLL_MULT));
else if (key == 3)
return (pl->pos_x - (pl->dir_x * (FT_COLL_MULT / 2)));
- return (1);
+ return ((uint64_t)pl->pos_x);
}
static uint64_t
@@ -40,9 +40,10 @@ static uint64_t
return (pl->pos_y - (pl->dir_x * FT_COLL_MULT));
else if (key == 3)
return (pl->pos_y + (pl->dir_y * (FT_COLL_MULT / 2)));
- return (1);
+ return ((uint64_t)pl->pos_y);
}
+#include <stdio.h>
static void
ft_collision(float old_y, float old_x, int32_t key, t_cub *cl)
{
@@ -75,8 +76,12 @@ int
ft_collision(old_y, old_x, cl->key_input[i], cl);
if (cl->mlist.isnlvl)
{
- if (ft_warp_level(cl) < 0)
- return (ft_exit(FT_RET_FAILED_STRUCTS, cl));
+ if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx &&
+ (uint32_t)cl->plist.pos_y == cl->mlist.nly)
+ {
+ return ((ft_warp_level(cl) < 0) ?
+ (ft_exit(FT_RET_FAILED_STRUCTS, cl)) : (0));
+ }
}
i++;
}
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 3c9110f..a4f705b 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -47,16 +47,7 @@ static void
{
uint8_t i;
- cl->plist.pos_x = 0;
- cl->plist.pos_y = 0;
- cl->plist.pos_z = 0;
- cl->plist.start_x = 0;
- cl->plist.start_y = 0;
- cl->plist.cam_x = 0;
- cl->plist.dir_x = -1;
- cl->plist.dir_y = 0;
- cl->plist.plane_x = 0;
- cl->plist.plane_y = 0.66;
+ cl->plist = ft_init_player();
cl->f_rgb = ft_init_rgb();
cl->c_rgb = ft_init_rgb();
cl->rlist = ft_init_s_ray();
@@ -70,6 +61,8 @@ static void
mlx_destroy_image(cl->wlist.wlx, cl->tlist[6].img);
if (cl->mlist.isctex && cl->tlist[7].img)
mlx_destroy_image(cl->wlist.wlx, cl->tlist[7].img);
+ if (cl->mlist.istrap && cl->tlist[15].img)
+ mlx_destroy_image(cl->wlist.wlx, cl->tlist[15].img);
}
static void
@@ -100,9 +93,6 @@ int8_t
char *tmp_mup;
uint8_t isoldmus;
- if ((uint32_t)cl->plist.pos_x == cl->mlist.nlx &&
- (uint32_t)cl->plist.pos_y == cl->mlist.nly)
- {
if (!(next_path = (char *)malloc((ft_strlen(
cl->mlist.nlevel_path) + 1) * sizeof(char))))
return (-1);
@@ -119,6 +109,5 @@ int8_t
ft_memdel((void**)&tmp_mup);
ft_wall_tex_init(cl);
ft_memdel((void**)&next_path);
- }
return (0);
}