diff --git a/includes/Cub3D.h b/includes/Cub3D.h index d93a184..af638fe 100644 --- a/includes/Cub3D.h +++ b/includes/Cub3D.h @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/13 16:30:59 by apommier #+# #+# */ -/* Updated: 2022/05/04 18:46:58 by apommier ### ########.fr */ +/* Updated: 2022/05/05 02:58:26 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,6 +52,7 @@ typedef struct s_data { player player; } t_data; +int get_color(char one, char two, char three); int reset_angle(int angle); float deg_to_rad(int angle); void draw_ray(t_data *img); diff --git a/srcs/cast_ray.c b/srcs/cast_ray.c index 0fc75f2..5728982 100644 --- a/srcs/cast_ray.c +++ b/srcs/cast_ray.c @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/05/04 18:08:14 by apommier #+# #+# */ -/* Updated: 2022/05/05 02:51:15 by apommier ### ########.fr */ +/* Updated: 2022/05/05 02:59:14 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,6 +29,19 @@ void print_ray2(t_data *img, float vx, float vy, float dist) } } +int get_color(char one, char two, char three) +{ + int color = 0; + + color = color << 8; + color += one; + color = color << 8; + color += two; + color = color << 8; + color += three; + return (color); +} + int get_red() { int red = 0; diff --git a/srcs/main.c b/srcs/main.c index dfda7ba..dd1f3fd 100644 --- a/srcs/main.c +++ b/srcs/main.c @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/13 16:42:55 by apommier #+# #+# */ -/* Updated: 2022/05/05 02:52:35 by apommier ### ########.fr */ +/* Updated: 2022/05/05 02:55:40 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -206,7 +206,7 @@ int main(int argc, char **argv) img.player.vy = sin(deg_to_rad(img.player.angle)); print_map(img.map, &img); print_player(img.player, &img); - print_ray(&img); + //print_ray(&img); mlx_hook(img.mlx_win, 2, 1L << 0, &key_press, &img); mlx_hook(img.mlx_win, 17, 0L, &quit_game, &img); mlx_loop(img.mlx); diff --git a/srcs/utils.c b/srcs/utils.c index 8c75cd0..18fb255 100644 --- a/srcs/utils.c +++ b/srcs/utils.c @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/02/13 23:37:02 by apommier #+# #+# */ -/* Updated: 2022/05/05 02:53:07 by apommier ### ########.fr */ +/* Updated: 2022/05/05 03:05:12 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -98,6 +98,24 @@ int is_good(t_data *img, int type) return (1); } +void print_back(t_data *img) +{ + int x = 530; + int y = 160; + + while (x < 1024) + { + y = 0; + while (y < 320) + { + mlx_pixel_put(img->mlx, img->mlx_win, x , y, get_color(128, 128, 128)); + //mlx_pixel_put(img->mlx, img->mlx_win, x , y - 160, get_color(0, 255, 255)); + y++; + } + x++; + } +} + int key_press(int code, t_data *img) { if (code == 65307) @@ -107,9 +125,10 @@ int key_press(int code, t_data *img) if (is_good(img, code)) { //printf("code = %d\n", code); - mlx_clear_window(img->mlx, img->mlx_win); + //mlx_clear_window(img->mlx, img->mlx_win); print_map(img->map, img); print_player(img->player, img); + print_back(img); draw_ray(img); print_ray(img); }