Skip to content

Commit

Permalink
improved rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Iipal committed Feb 13, 2019
1 parent ef4a7f6 commit ffadeb2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
3 changes: 2 additions & 1 deletion includes/wolf3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/06 14:30:10 by tmaluh #+# #+# */
/* Updated: 2019/02/13 19:49:24 by tmaluh ### ########.fr */
/* Updated: 2019/02/13 22:02:28 by tmaluh ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -66,6 +66,7 @@ typedef struct s_mlx

typedef struct s_isrender
{
bool is_render;
bool is_boost_step;
bool is_textured;
bool is_press_mouse;
Expand Down
3 changes: 2 additions & 1 deletion includes/wolf3d_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/06 14:34:31 by tmaluh #+# #+# */
/* Updated: 2019/02/13 19:48:38 by tmaluh ### ########.fr */
/* Updated: 2019/02/13 21:58:24 by tmaluh ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -106,6 +106,7 @@
# define ISRB env->isr->is_boost_step
# define ISRM env->isr->is_press_mouse
# define ISRT env->isr->is_textured
# define ISRR env->isr->is_render

# define MOUSE env->mouse

Expand Down
4 changes: 2 additions & 2 deletions srcs/wolf_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/06 14:38:13 by tmaluh #+# #+# */
/* Updated: 2019/02/13 18:30:12 by tmaluh ### ########.fr */
/* Updated: 2019/02/13 22:01:58 by tmaluh ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -72,7 +72,7 @@ bool wolf_init(t_env *env)
_NOTIS_F(env->rc = (t_rc*)malloc(sizeof(t_rc)));
_NOTIS_F(MOUSE = (t_mouse*)malloc(sizeof(t_mouse)));
_NOTIS_F(TEX = (t_xpm*)(malloc(sizeof(t_xpm) * (MAX_TEXTURES + 2))));
*(env->isr) = (t_isr){false, true, false};
*(env->isr) = (t_isr){true, false, true, false};
_NOTIS_F(add_init_textures(env));
return (true);
}
26 changes: 14 additions & 12 deletions srcs/wolf_key_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/06 14:44:03 by tmaluh #+# #+# */
/* Updated: 2019/02/13 19:19:32 by tmaluh ### ########.fr */
/* Updated: 2019/02/13 22:00:02 by tmaluh ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -21,40 +21,42 @@ int wolf_killwindow(t_env *env)

static void add_action_wasd(int key, t_env *env)
{
if (key == KEY_W)
if (key == KEY_W && (ISRR = true))
wolf_move(env, ISRB ? (MOVE_BOOST * MOVE_INC) : MOVE_INC);
if (key == KEY_A)
if (key == KEY_A && (ISRR = true))
wolf_rotate(RC, _RAD(ISRB ? (ROT_BOOST * ROT_INC) : ROT_INC));
if (key == KEY_S)
if (key == KEY_S && (ISRR = true))
wolf_move(env, ISRB ? (MOVE_BOOST * -MOVE_INC) : -MOVE_INC);
if (key == KEY_D)
if (key == KEY_D && (ISRR = true))
wolf_rotate(RC, _RAD(ISRB ? (ROT_BOOST * -ROT_INC) : -ROT_INC));
}

static void add_action_arrows(int key, t_env *env)
{
if (key == ARROW_UP)
if (key == ARROW_UP && (ISRR = true))
wolf_move(env, ISRB ? (MOVE_BOOST * MOVE_INC) : MOVE_INC);
if (key == ARROW_DOWN)
if (key == ARROW_DOWN && (ISRR = true))
wolf_move(env, ISRB ? (MOVE_BOOST * -MOVE_INC) : -MOVE_INC);
if (key == ARROW_LEFT)
if (key == ARROW_LEFT && (ISRR = true))
wolf_rotate(RC, _RAD(ISRB ? (ROT_BOOST * ROT_INC) : ROT_INC));
if (key == ARROW_RIGHT)
if (key == ARROW_RIGHT && (ISRR = true))
wolf_rotate(RC, _RAD(ISRB ? (ROT_BOOST * -ROT_INC) : -ROT_INC));
}

int wolf_key_hooks(int key, t_env *env)
{
ISRR = false;
if (key == ESC)
wolf_killwindow(env);
if (key == LSHIFT)
if (key == LSHIFT && (ISRR = true))
ISRB ? (ISRB = false)
: (ISRB = true);
if (key == KEY_T)
if (key == KEY_T && (ISRR = true))
ISRT ? (ISRT = false)
: (ISRT = true);
add_action_wasd(key, env);
add_action_arrows(key, env);
wolf_rendering_rc(env);
if (ISRR)
wolf_rendering_rc(env);
return (0);
}
4 changes: 2 additions & 2 deletions srcs/wolf_rendering.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/06 22:03:53 by tmaluh #+# #+# */
/* Updated: 2019/02/13 18:25:21 by tmaluh ### ########.fr */
/* Updated: 2019/02/13 22:01:27 by tmaluh ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -39,6 +39,7 @@ void wolf_rendering_rc(t_env *env)
{
point p;

ft_bzero(SPTR, sizeof(int) * WIN_X * WIN_Y);
if (!ISRT)
add_fill_floor_is_colored(env->mlx);
p.x = -1;
Expand All @@ -58,5 +59,4 @@ void wolf_rendering_rc(t_env *env)
ISRT ? wolf_render_textured(env, &p) : add_render_colored(env, &p);
}
mlx_put_image_to_window(MPTR, WPTR, IPTR, 0, 0);
ft_bzero(SPTR, sizeof(int) * WIN_X * WIN_Y);
}

0 comments on commit ffadeb2

Please sign in to comment.