From 679b5dced1d73d9284bab8965e2f3bf37b3056f4 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 30 Jan 2020 14:18:41 +0100 Subject: fixed ceilling/floor color --- cub3d.h | 10 ++++------ event.c | 5 +++-- main.c | 2 +- minimalist.cub | 4 ++-- parse/parse_color.c | 8 ++++---- render.c | 7 ++----- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/cub3d.h b/cub3d.h index 5f48648..00a3374 100644 --- a/cub3d.h +++ b/cub3d.h @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/15 06:40:37 by cacharle #+# #+# */ -/* Updated: 2020/01/30 12:04:26 by cacharle ### ########.fr */ +/* Updated: 2020/01/30 14:17:19 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include @@ -53,10 +53,10 @@ typedef union unsigned int hexcode; struct { - t_byte empty; - t_byte r; - t_byte g; t_byte b; + t_byte g; + t_byte r; + t_byte empty; } rgb; } t_color; @@ -100,8 +100,6 @@ typedef struct s_state t_bool running; void *mlx_ptr; void *window_ptr; - int window_width; - int window_height; t_vector pos; t_vector dir; t_vector plane; diff --git a/event.c b/event.c index 318e9e6..0c71267 100644 --- a/event.c +++ b/event.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/15 06:39:37 by cacharle #+# #+# */ -/* Updated: 2020/01/17 13:59:48 by cacharle ### ########.fr */ +/* Updated: 2020/01/30 14:18:13 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,7 +38,8 @@ int event_keydown(int key, t_state *state) return (0); } -int event_quit(t_state *state) +int event_quit(t_state *state) { state->running = FALSE; + return (0); } diff --git a/main.c b/main.c index d596788..00a041d 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/15 06:39:39 by cacharle #+# #+# */ -/* Updated: 2020/01/30 12:47:56 by cacharle ### ########.fr */ +/* Updated: 2020/01/30 14:02:58 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/minimalist.cub b/minimalist.cub index c0c9a7e..f2d39e7 100644 --- a/minimalist.cub +++ b/minimalist.cub @@ -5,8 +5,8 @@ WE ./textures/brick.xpm EA ./textures/brick.xpm S ./textures/brick.xpm -F 220,0,0 -C 0,225,0 +F 0,225,0 +C 200,200,0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 diff --git a/parse/parse_color.c b/parse/parse_color.c index f602706..fd482e5 100644 --- a/parse/parse_color.c +++ b/parse/parse_color.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/11 09:52:34 by cacharle #+# #+# */ -/* Updated: 2020/01/11 10:14:29 by cacharle ### ########.fr */ +/* Updated: 2020/01/30 14:17:37 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,8 +16,8 @@ t_bool parse_ceilling_color(t_state *state, char *line) { int tmp; - line++; - if ((tmp = ft_atoi(line)) > 255 || tmp < 0) + state->ceilling_color.hexcode = 0x0; + if ((tmp = ft_atoi(line)) > 255 || tmp < 0) // cant do atoi due to overflow stuff, use ft_strtol return (FALSE); state->ceilling_color.rgb.r = (t_byte)tmp; if ((line = ft_strchr(line, ',') + 1) == NULL) @@ -37,7 +37,7 @@ t_bool parse_floor_color(t_state *state, char *line) { int tmp; - line++; + state->floor_color.hexcode = 0x0; if ((tmp = ft_atoi(line)) > 255 || tmp < 0) return (FALSE); state->floor_color.rgb.r = (t_byte)tmp; diff --git a/render.c b/render.c index 756e6ce..8a70f70 100644 --- a/render.c +++ b/render.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/11 13:37:17 by cacharle #+# #+# */ -/* Updated: 2020/01/30 13:38:35 by cacharle ### ########.fr */ +/* Updated: 2020/01/30 14:16:36 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,7 +23,6 @@ int render_update(void *param) exit(EXIT_SUCCESS); return (0); } - ft_bzero(state->window.data, state->window.width * state->window.height * 4); render_update_window(state); mlx_put_image_to_window(state->mlx_ptr, state->window_ptr, state->window.id, 0, 0); return (0); @@ -69,16 +68,14 @@ void render_window_column(t_state *state, t_render_state *rstate) { int i; t_color white; - t_color black; white.hexcode = 0x00ffffff; - black.hexcode = 0x00000000; i = 0; while (i < rstate->draw_start) ((t_color*)state->window.data)[i++ * state->window.width + rstate->x] = state->ceilling_color; while (i < rstate->draw_end) ((t_color*)state->window.data)[i++ * state->window.width + rstate->x] = white; - while (i < state->window_height) + while (i < state->window.height) ((t_color*)state->window.data)[i++ * state->window.width + rstate->x] = state->floor_color; /* while (++i < rstate->draw_start) */ -- cgit