aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--inc/cub3d_structs.h1
-rw-r--r--map/lvl_five.cub2
-rw-r--r--map/lvl_four.cub1
-rw-r--r--map/lvl_one.cub4
-rw-r--r--map/lvl_three.cub2
-rw-r--r--map/lvl_two.cub2
-rw-r--r--src/ft_exit.c2
-rw-r--r--src/ft_get_music.c4
-rw-r--r--src/ft_init_lists.c1
-rw-r--r--src/ft_music.c2
-rw-r--r--src/ft_warp_level.c28
12 files changed, 43 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 8f1b21c..5194aa6 100644
--- a/Makefile
+++ b/Makefile
@@ -144,8 +144,8 @@ else
@$(MAKE) --no-print-directory -C ${LFT_DIR} all
endif
ifeq (${OS}, Darwin)
- ${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -L${MLX_DIR} -lft -lmlx -lm -framework OpenGL \
--framework AppKit
+ ${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -L${MLX_DIR} -lft -lmlx -lm -lpthread \
+-framework OpenGL -framework AppKit
else
${CC} ${CFLAGS} -o $@ ${OBJS} -L${LFT_DIR} -lft -lX11 -lXext -lmlx -lm -lbsd -lpthread
endif
diff --git a/inc/cub3d_structs.h b/inc/cub3d_structs.h
index 5f1b743..b7d49a7 100644
--- a/inc/cub3d_structs.h
+++ b/inc/cub3d_structs.h
@@ -136,6 +136,7 @@ typedef struct s_cub
uint8_t w_side;
uint8_t ishud;
uint8_t walltexgood;
+ uint8_t isoldmus;
uint16_t currlvl;
uint16_t i;
char errmsg[64];
diff --git a/map/lvl_five.cub b/map/lvl_five.cub
index 20ddf26..6541283 100644
--- a/map/lvl_five.cub
+++ b/map/lvl_five.cub
@@ -12,6 +12,8 @@ F 100,100,100
LT ./media/img/larry.xpm
L ./map/map_four.cub
+MU ./media/sound/DEVANT-LES-KAISSONS.wav
+
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1
diff --git a/map/lvl_four.cub b/map/lvl_four.cub
index 759933d..5bf92da 100644
--- a/map/lvl_four.cub
+++ b/map/lvl_four.cub
@@ -8,6 +8,7 @@ S ./media/img/pillar.xpm
C 180,70,110
F 100,140,114
+MU ./media/sound/DEVANT-LES-KAISSONS.wav
LT ./media/img/plate.xpm
L ./map/lvl_five.cub
diff --git a/map/lvl_one.cub b/map/lvl_one.cub
index ae0f78c..0151dc4 100644
--- a/map/lvl_one.cub
+++ b/map/lvl_one.cub
@@ -15,8 +15,8 @@ LT ./media/img/crapaud.xpm
MU ./media/sound/DEVANT-LES-KAISSONS.wav
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
-1 1 1 1 1 1 1 1 1 1 1 1 L 0 0 0 W 1
+1 1 1 1 1 1 1 1 1 1 1 1 L 0 0 0 0 1
1 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
+1 E 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
diff --git a/map/lvl_three.cub b/map/lvl_three.cub
index b05ab2d..d019f0a 100644
--- a/map/lvl_three.cub
+++ b/map/lvl_three.cub
@@ -12,6 +12,8 @@ F 100,160,114
LT ./media/img/crapaud.xpm
L ./map/lvl_four.cub
+MU ./media/sound/DEVANT-LES-KAISSONS.wav
+
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1
diff --git a/map/lvl_two.cub b/map/lvl_two.cub
index 29d7eb7..9157634 100644
--- a/map/lvl_two.cub
+++ b/map/lvl_two.cub
@@ -12,6 +12,8 @@ F 50,190,124
L ./map/lvl_three.cub
LT ./media/img/crapaud.xpm
+MU ./media/sound/DEVANT-LES-KAISSONS.wav
+
1 1 1
1 0 1
1 N 1
diff --git a/src/ft_exit.c b/src/ft_exit.c
index a19bff3..c022627 100644
--- a/src/ft_exit.c
+++ b/src/ft_exit.c
@@ -63,7 +63,7 @@ int
mlx_destroy_window(clist->wlist->wlx, clist->wlist->winptr);
clist->wlist->winptr = NULL;
}
- if (clist->mlist->ismusic)
+ if (clist->isoldmus && clist->wlist->inited)
{
pthread_cancel(clist->tid);
pthread_join(clist->tid, NULL);
diff --git a/src/ft_get_music.c b/src/ft_get_music.c
index 21c6331..df65a7f 100644
--- a/src/ft_get_music.c
+++ b/src/ft_get_music.c
@@ -30,8 +30,8 @@ static void
return ;
if (FT_OS == 2)
{
- ft_sprintf(mlist->music_cmd,
- "aplay -f cd -t wav -q %s", mlist->music_path);
+ ft_sprintf(mlist->music_cmd, "aplay -f cd -t wav -q %s",
+ mlist->music_path);
}
else {}
}
diff --git a/src/ft_init_lists.c b/src/ft_init_lists.c
index fd8c75d..eec8d5d 100644
--- a/src/ft_init_lists.c
+++ b/src/ft_init_lists.c
@@ -81,6 +81,7 @@ static t_cub
while (++i < 5)
clist->key_input[i] = -1;
clist->ishud = 0;
+ clist->isoldmus = 0;
clist->f_rgb = ft_init_rgb();
clist->c_rgb = ft_init_rgb();
clist->rlist = ft_init_s_ray();
diff --git a/src/ft_music.c b/src/ft_music.c
index 5eed915..d110256 100644
--- a/src/ft_music.c
+++ b/src/ft_music.c
@@ -22,7 +22,7 @@ void
t_cub *cl;
cl = (t_cub *)vargp;
- ft_printf("%s\n", cl->mlist->music_cmd);
+ cl->isoldmus = 1;
system(cl->mlist->music_cmd);
return (NULL);
}
diff --git a/src/ft_warp_level.c b/src/ft_warp_level.c
index 41d1a45..de87187 100644
--- a/src/ft_warp_level.c
+++ b/src/ft_warp_level.c
@@ -53,23 +53,41 @@ static void
cl->c_rgb = ft_init_rgb();
cl->rlist = ft_init_s_ray();
i = 0;
- while (i < 5)
+ while (i <= 5)
{
mlx_destroy_image(cl->wlist->wlx, cl->tlist[i].img);
cl->tlist[i].img = NULL;
i++;
}
- if (cl->mlist->ismusic)
+}
+
+static void
+ ft_treat_music(uint8_t isoldmus, char *tmp_mup, t_cub *cl)
+{
+ if (isoldmus && !cl->mlist->ismusic)
+ {
+ pthread_cancel(cl->tid);
+ pthread_join(cl->tid, NULL);
+ cl->isoldmus = 0;
+ }
+ else if (isoldmus && cl->mlist->ismusic
+ && ft_strncmp(tmp_mup, cl->mlist->music_path, ft_strlen(tmp_mup) + 1))
{
pthread_cancel(cl->tid);
pthread_join(cl->tid, NULL);
+ pthread_create(&cl->tid, NULL, ft_music_thread, cl);
}
+ else if (isoldmus && cl->mlist->ismusic
+ && !ft_strncmp(tmp_mup, cl->mlist->music_path, ft_strlen(tmp_mup) + 1))
+ return ;
}
int8_t
ft_warp_level(t_cub *cl)
{
char *next_path;
+ 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)
@@ -78,11 +96,17 @@ int8_t
cl->mlist->nlevel_path) + 1) * sizeof(char))))
return (-1);
ft_sprintf(next_path, "%s", cl->mlist->nlevel_path);
+ isoldmus = cl->mlist->ismusic;
+ if (isoldmus)
+ tmp_mup = ft_strdup(cl->mlist->music_path);
ft_del_some(cl);
ft_del_map(cl->mlist);
if (!(cl->mlist = ft_init_map()))
return (-1);
ft_parse_map(next_path, cl);
+ ft_treat_music(isoldmus, tmp_mup, cl);
+ if (isoldmus)
+ ft_memdel((void**)&tmp_mup);
ft_wall_tex_init(cl);
ft_memdel((void**)&next_path);
}