aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h2
-rw-r--r--src/ft_draw_circle.c41
-rw-r--r--src/ft_draw_map.c6
-rw-r--r--src/ft_draw_scene.c2
-rw-r--r--src/ft_raycasting.c1
-rw-r--r--src/main.c1
7 files changed, 49 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 3a89cf8..a120b23 100644
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,7 @@ SRCS_NAME += ft_free_words.c
SRCS_NAME += ft_map_error.c
SRCS_NAME += ft_init_winlx.c
SRCS_NAME += ft_draw_square.c
+SRCS_NAME += ft_draw_circle.c
SRCS_NAME += ft_draw_map.c
SRCS_NAME += ft_draw_scene.c
SRCS_NAME += ft_basic_keys.c
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 2362d07..22ce582 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -78,5 +78,7 @@ int ft_key_release(int keycode, t_cub *clist);
int8_t ft_check_ext(const char *filep, const char *ext);
int32_t ft_convert_keycode(const int32_t tmp_code);
int ft_key_loop(t_cub *cl);
+void ft_draw_circle(int32_t a, int32_t b,
+ int32_t color, t_cub *cl);
# endif
diff --git a/src/ft_draw_circle.c b/src/ft_draw_circle.c
new file mode 100644
index 0000000..32a1612
--- /dev/null
+++ b/src/ft_draw_circle.c
@@ -0,0 +1,41 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_draw_circle.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/18 15:22:51 by rbousset #+# #+# */
+/* Updated: 2020/02/18 15:22:53 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <mlx.h>
+#include <stdint.h>
+#include <math.h>
+
+void
+ ft_draw_circle(int32_t a, int32_t b, int32_t color, t_cub *cl)
+{
+ const uint16_t scale = cl->mlist->scale / 2.5;
+ int x;
+ int y;
+ float i;
+ float angle;
+ float x1;
+ float y1;
+
+ x = a;
+ y = b;
+
+ i = 0;
+ while (i < 360)
+ {
+ angle = i;
+ x1 = scale * cos(angle * M_PI / 180);
+ y1 = scale * sin(angle * M_PI / 180);
+ *(int*)(cl->img.ptr + (x + (int)x1) * 4 + ((y + (int)y1) * cl->img.sizeline)) = color;
+ i += 0.1;
+ }
+}
diff --git a/src/ft_draw_map.c b/src/ft_draw_map.c
index 2e17d69..7da2e58 100644
--- a/src/ft_draw_map.c
+++ b/src/ft_draw_map.c
@@ -28,9 +28,9 @@ static void
const float y = plist->pos_y;
const uint16_t scale = clist->mlist->scale;
- ft_draw_square(
- scale + (x * (scale)),
- ft_y_offset(clist) + (y * (scale)),
+ ft_draw_circle(
+ (scale / 2 ) + (x * (scale)),
+ ft_y_offset(clist) - (scale) + (y * (scale)),
0x009843fa,
clist);
}
diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c
index ec2cc89..966d357 100644
--- a/src/ft_draw_scene.c
+++ b/src/ft_draw_scene.c
@@ -18,7 +18,7 @@
void
ft_draw_scene(t_cub *clist)
{
- mlx_clear_window(clist->wlist->wlx, clist->wlist->winptr);
+ /* mlx_clear_window(clist->wlist->wlx, clist->wlist->winptr); */
clist->img.img = mlx_new_image(clist->wlist->wlx,
clist->wlist->x_size, clist->wlist->y_size);
clist->img.ptr = mlx_get_data_addr(clist->img.img, &clist->img.bpp,
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index ff73893..9a89dc4 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -71,7 +71,6 @@ void
i = 0;
wl = cl->wlist;
- ft_wall_tex_init(cl);
while (i < wl->x_size)
{
ft_initray(cl, i);
diff --git a/src/main.c b/src/main.c
index d102838..52bb211 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,6 +31,7 @@ int
ft_parse_map(argv[1], clist);
if (ft_init_winlx(clist) < 0)
return (ft_exit(3, clist));
+ ft_wall_tex_init(clist);
ft_draw_scene(clist);
ft_hooks_and_loops(clist->wlist, clist);
return (0);