diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | inc/cub3d.h | 5 | ||||
-rw-r--r-- | src/ft_draw_circle.c | 41 | ||||
-rw-r--r-- | src/ft_draw_map.c | 6 | ||||
-rw-r--r-- | src/ft_draw_scene.c | 1 | ||||
-rw-r--r-- | src/ft_init_lists.c | 3 |
6 files changed, 52 insertions, 5 deletions
@@ -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 d3e018e..d2594f9 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -78,6 +78,11 @@ 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); +<<<<<<< HEAD +void ft_draw_circle(int32_t a, int32_t b, + int32_t color, t_cub *cl); +======= void ft_draw_texture(t_cub *cl, int x, int y, int tex_y); +>>>>>>> textures # 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 60198e9..3bf453a 100644 --- a/src/ft_draw_scene.c +++ b/src/ft_draw_scene.c @@ -18,7 +18,6 @@ void ft_draw_scene(t_cub *clist) { - /*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_init_lists.c b/src/ft_init_lists.c index 90b8638..b8d7c7c 100644 --- a/src/ft_init_lists.c +++ b/src/ft_init_lists.c @@ -16,6 +16,7 @@ #include <stddef.h> #include <stdlib.h> #include <limits.h> +#include <math.h> static t_rgb ft_init_rgb(void) @@ -41,7 +42,7 @@ static t_player plist->dir_x = -1; plist->dir_y = 0; plist->plane_x = 0; - plist->plane_y = 0.66; + plist->plane_y = 0.66666666; return (plist); } |