From e821fb7ab1232349f0be023b08dafee75da02ea9 Mon Sep 17 00:00:00 2001 From: Rudy Bousset Date: Mon, 9 Mar 2020 21:01:07 +0100 Subject: Almost there --- Makefile | 1 + inc/cub3d.h | 1 + src/ft_draw_scene.c | 2 ++ src/ft_draw_skybox.c | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) create mode 100644 src/ft_draw_skybox.c diff --git a/Makefile b/Makefile index 9fc6143..6e6bcb2 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ 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_draw_skybox.c SRCS_NAME += ft_basic_keys.c SRCS_NAME += ft_extra_keys.c SRCS_NAME += ft_draw_verline.c diff --git a/inc/cub3d.h b/inc/cub3d.h index 6201b91..7de1df7 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -77,6 +77,7 @@ void ft_sprite_height(t_cub *cl, t_sprite *sprite); void ft_calc_sprite(t_cub *cl); void ft_draw_sprite(t_cub *cl, t_sprite *sprite); void ft_get_sprite_spawn(t_cub *cl); +void ft_draw_skybox(t_cub *cl); /* ** ====== PARSING ====== diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c index 68a72e9..2cfa3f4 100644 --- a/src/ft_draw_scene.c +++ b/src/ft_draw_scene.c @@ -50,6 +50,8 @@ void { ft_draw_hud(clist); } + if (clist->mlist.isskybox) + ft_draw_skybox(clist); ft_calc_sprite(clist); mlx_put_image_to_window(clist->wlist.wlx, clist->wlist.winptr, clist->img.img, 0, 0); diff --git a/src/ft_draw_skybox.c b/src/ft_draw_skybox.c new file mode 100644 index 0000000..a446485 --- /dev/null +++ b/src/ft_draw_skybox.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_draw_skybox.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:22:57 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:23:42 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include + +void + ft_draw_skybox(t_cub *cl) +{ + int offset; + + offset = 640; + if (cl->plist.dir_x > 0) + offset = -offset; + mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, + cl->tlist[7].img, offset * cl->plist.dir_y, -125); + mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, + cl->tlist[7].img, offset * cl->plist.dir_y, -125); + mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, + cl->tlist[7].img, offset * cl->plist.dir_y, -125); + mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, + cl->tlist[7].img, offset * cl->plist.dir_y, -125); + mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, + cl->tlist[7].img, offset * cl->plist.dir_y, -125); + mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, + cl->tlist[7].img, offset * cl->plist.dir_y, -125); + mlx_put_image_to_window(cl->wlist.wlx, cl->wlist.winptr, + cl->tlist[7].img, offset * cl->plist.dir_y, -125); +} -- cgit v1.2.3