aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-30 13:54:11 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-30 13:54:11 +0200
commita6dbe3b5710f719b3f02ba0044a72c64ee4155ac (patch)
treec1f64e3cfec00bd5b20d9f624370644fc8e62ef4
parentBetter sword (diff)
download42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.gz
42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.bz2
42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.xz
42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.tar.zst
42-cub3d-a6dbe3b5710f719b3f02ba0044a72c64ee4155ac.zip
Bug fix
Diffstat (limited to '')
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h11
-rw-r--r--map/lvl_five.cub2
-rw-r--r--map/map_seven.cub27
-rw-r--r--src/ft_get_fps_count.c21
-rw-r--r--src/ft_shoot.c6
-rw-r--r--src/ft_time.c37
7 files changed, 79 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index b5ae41d..59b009e 100644
--- a/Makefile
+++ b/Makefile
@@ -125,6 +125,7 @@ SRCS_NAME += ft_floor_threads.c
SRCS_NAME += ft_castray_loop.c
SRCS_NAME += ft_sort_s_t.c
SRCS_NAME += ft_big_t.c
+SRCS_NAME += ft_time.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 84d9ea1..50f2bf3 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -17,6 +17,7 @@
#include <cub3d_structs.h>
#include <stddef.h>
#include <stdint.h>
+#include <time.h>
/*
** ====== STRUCTS ======
@@ -229,6 +230,14 @@ void *ft_sfx_weapon_three_fire_thread(void *vargp);
void *ft_sfx_ooa_thread(void *vargp);
/*
+** ====== TIMINGS ======
+*/
+
+float ft_clock_to_ms(clock_t ticks);
+void ft_handle_firing(clock_t dt, t_cub *cl);
+void ft_get_fps_count(clock_t delta_time, t_cub *cl);
+
+/*
** ====== DELETION ======
*/
@@ -246,14 +255,12 @@ int ft_exit(uint8_t exit_code, t_cub *clist);
void ft_set_minimap_scale(t_cub *clist);
void ft_enable_music(t_cub *cl);
-void ft_music_fork(char **mcmd_words, char *const envp[]);
int8_t ft_save_to_bmp(t_cub *cl);
int8_t ft_warp_level(char *path, t_cub *cl);
uint32_t ft_rgb_to_hex(float dist, t_rgb rgb, t_cub *cl);
t_bmp_rgb ft_hex_to_rgb(uint32_t color);
uint32_t ft_darken(t_rgb rgb, t_cub *cl);
void ft_death_screen(t_cub *cl);
-void ft_get_fps_count(clock_t delta_time, t_cub *cl);
void ft_find_item(t_player *pl, t_map *ml, t_cub *cl);
int8_t ft_switch_weap_one(t_cub *cl);
int8_t ft_switch_weap_two(t_cub *cl);
diff --git a/map/lvl_five.cub b/map/lvl_five.cub
index bb7ef45..4d14045 100644
--- a/map/lvl_five.cub
+++ b/map/lvl_five.cub
@@ -21,7 +21,7 @@ MU ./media/sound/BITURE-ET-MELANCOLIE.wav
11111101111110110111111110111111
1111101 101T01 10000001
1000001 11101101 1111110111111
- 11T1101 1+#00001 1T00000000001
+ 11T1101 1+0#0001 1T00000000001
1+1101 111111101 1111111111101
111101 101 101 1000001 101
1011101 101 1011101 101
diff --git a/map/map_seven.cub b/map/map_seven.cub
new file mode 100644
index 0000000..5985113
--- /dev/null
+++ b/map/map_seven.cub
@@ -0,0 +1,27 @@
+R 1331 998
+
+NO ./media/img/tex/plate_small.xpm
+SO ./media/img/tex/plate_small.xpm
+EA ./media/img/tex/plate_small.xpm
+WE ./media/img/tex/plate_small.xpm
+S ./media/img/sprites/pillar.xpm
+
+F 150,150,150
+C 150,150,150
+
+
+1111111111111111111
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+1000000000000000001
+10000000@0000000001
+10000000N0000000001
+1111111111111111111
diff --git a/src/ft_get_fps_count.c b/src/ft_get_fps_count.c
index f7f0177..1f717e8 100644
--- a/src/ft_get_fps_count.c
+++ b/src/ft_get_fps_count.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_key_loop.c :+: :+: :+: */
+/* ft_get_fps_count.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -16,25 +16,6 @@
#include <stdint.h>
#include <time.h>
-static float
- ft_clock_to_ms(clock_t ticks)
-{
- return ((ticks / (float)CLOCKS_PER_SEC) * 1000.0);
-}
-
-static void
- ft_handle_firing(clock_t dt, t_cub *cl)
-{
- static clock_t curr_time = 0;
-
- curr_time += dt;
- if (dt > 0 && ft_clock_to_ms(curr_time) > 300.0)
- {
- cl->plist.fire = 0;
- curr_time -= CLOCKS_PER_SEC;
- }
-}
-
void
ft_get_fps_count(clock_t dt, t_cub *cl)
{
diff --git a/src/ft_shoot.c b/src/ft_shoot.c
index 09061b8..7f23bfd 100644
--- a/src/ft_shoot.c
+++ b/src/ft_shoot.c
@@ -49,9 +49,9 @@ static int8_t
{
if (cl->plist.handles_weapon == 0 &&
sqrtf(powf(cl->plist.pos_x - cl->rlist.sqy, 2)
- + powf(cl->plist.pos_y - cl->rlist.sqx, 2)) < 1.5)
- return (1);
- return (0);
+ + powf(cl->plist.pos_y - cl->rlist.sqx, 2)) > 1.7)
+ return (0);
+ return (1);
}
static void
diff --git a/src/ft_time.c b/src/ft_time.c
new file mode 100644
index 0000000..2be702d
--- /dev/null
+++ b/src/ft_time.c
@@ -0,0 +1,37 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_get_fps_count.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/17 20:06:26 by rbousset #+# #+# */
+/* Updated: 2020/02/17 20:06:29 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <libft.h>
+#include <cub3d.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <time.h>
+
+float
+ ft_clock_to_ms(clock_t ticks)
+{
+ return ((ticks * 1000.0) / (float)CLOCKS_PER_SEC);
+}
+
+void
+ ft_handle_firing(clock_t dt, t_cub *cl)
+{
+ static clock_t curr_time = 0;
+
+ curr_time += dt;
+ if (dt > 0 && ft_clock_to_ms(curr_time) > 300.0)
+ {
+ cl->plist.fire = 0;
+ curr_time -= CLOCKS_PER_SEC;
+ }
+}
+