diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 15 | ||||
| -rw-r--r-- | inc/cub3d.h | 6 | ||||
| -rw-r--r-- | src/ft_key_events.c | 56 | 
3 files changed, 27 insertions, 50 deletions
| @@ -52,8 +52,8 @@ MKDIR		= mkdir -p  RM			= rm -rf  OS			= $(shell uname)  ifeq (${OS}, Darwin) -	SCR_SZE = $(shell osascript -e 'tell application "Finder" to get bounds\ - of window of desktop' | tr ',' 'x' | tr -d '\n' | tr -d ' ' | cut -c 5-) +	SCR_SZE = $(shell osascript -e 'tell application "Finder" to get bounds of\ + window of desktop' | tr ',' 'x' | tr -d '\n' | tr -d ' ' | cut -c 5-)  else  	SCR_SZE	= $(shell xdpyinfo | grep dimensions | awk '{print $$2}')  endif @@ -66,11 +66,18 @@ CFLAGS		+= -Wall  CFLAGS		+= -Wextra  CFLAGS		+= -Werror  CFLAGS		+= -pedantic -CFLAGS		+= -DFT_SCR_SIZE=\"${SCR_SZE}\"  ifdef ASAN  	CFLAGS	+= ${DEBUG}  	CFLAGS	+= ${FSANITIZE}  endif +CDEFS		= -DFT_SCR_SIZE=\"${SCR_SZE}\" +ifeq (${OS}, Linux) +	CDEFS	+= -DFT_W_KEY=119 +	CDEFS	+= -DFT_A_KEY=97 +	CDEFS	+= -DFT_S_KEY=115 +	CDEFS	+= -DFT_D_KEY=100 +	CDEFS	+= -DFT_ESC_KEY=65307 +endif  #------------------------------------------------------------------------------#  DEBUG		= -glldb  FSANITIZE	= -fsanitize=address @@ -89,7 +96,7 @@ ifeq (${OS}, Darwin)  	${CC} -c ${CFLAGS} -I${LFT_DIR}${INCS_DIR} -I${MLX_DIR} -I${INCS_DIR} -o $@ $<  else  	${CC} -c ${CFLAGS} -I${LFT_DIR}${INCS_DIR} -I${INCS_DIR} \ --DFT_W_KEY=119 -DFT_A_KEY=97 -DFT_S_KEY=115 -DFT_D_KEY=100 -DFT_ESC_KEY=65307 \ + \  -o $@ $<  endif  #------------------------------------------------------------------------------# diff --git a/inc/cub3d.h b/inc/cub3d.h index ce7b0c1..deecf0d 100644 --- a/inc/cub3d.h +++ b/inc/cub3d.h @@ -29,6 +29,12 @@  #	ifndef FT_D_KEY  #	define FT_D_KEY 2  #	endif +#	ifndef FT_L_ARR_KEY +#	define FT_L_ARR_KEY 123 +#	endif +#	ifndef FT_R_ARR_KEY +#	define FT_R_ARR_KEY 124 +#	endif  #	ifndef FT_ESC_KEY  #	define FT_ESC_KEY 53  #	endif diff --git a/src/ft_key_events.c b/src/ft_key_events.c index d400684..5ca3d36 100644 --- a/src/ft_key_events.c +++ b/src/ft_key_events.c @@ -21,26 +21,8 @@ static int  	t_player	*pl;  	pl = clist->plist; -	if (pl->view_side == 1) -	{ -		if ((pl->pos_y -= 0.3) < 0.4) -			pl->pos_y = 0.4; -	} -	else if (pl->view_side == 2) -	{ -		if ((pl->pos_x += 0.3) > clist->map_w - 0.4) -			pl->pos_x = clist->map_w - 0.4; -	} -	else if (pl->view_side == 3) -	{ -		if ((pl->pos_y += 0.3) > clist->map_h - 0.4) -			pl->pos_y = clist->map_h - 0.4; -	} -	else if (pl->view_side == 4) -	{ -		if ((pl->pos_x -= 0.3) < 0.4) -			pl->pos_x = 0.4; -	} +	if ((pl->pos_y -= 0.3) < 0.4) +		pl->pos_y = 0.4;  	ft_drawmap(clist);  	return (0);  } @@ -51,9 +33,9 @@ static int  	t_player	*pl;  	pl = clist->plist; -	pl->view_side -= 1.0; -	if (pl->view_side < 1.0) -		pl->view_side = 4.0; +	if ((pl->pos_x -= 0.3) < 0.4) +		pl->pos_x = 0.4; +	ft_drawmap(clist);  	return (0);  } @@ -63,26 +45,8 @@ static int  	t_player	*pl;  	pl = clist->plist; -	if (pl->view_side == 1) -	{ -		if ((pl->pos_y += 0.3) > clist->map_h - 0.4) -			pl->pos_y = clist->map_h - 0.4; -	} -	else if (pl->view_side == 2) -	{ -		if ((pl->pos_x -= 0.3) < 0.4) -			pl->pos_x = 0.4; -	} -	else if (pl->view_side == 3) -	{ -		if ((pl->pos_y -= 0.3) < 0.4) -			pl->pos_y = 0.4; -	} -	else if (pl->view_side == 4) -	{ -		if ((pl->pos_x += 0.3) > clist->map_w - 0.4) -			pl->pos_x = clist->map_w - 0.4; -	} +	if ((pl->pos_y += 0.3) > clist->map_h - 0.4) +		pl->pos_y = clist->map_h - 0.4;  	ft_drawmap(clist);  	return (0);  } @@ -93,9 +57,9 @@ static int  	t_player	*pl;  	pl = clist->plist; -	pl->view_side += 1.0; -	if (pl->view_side > 4.0) -		pl->view_side = 1.0; +	if ((pl->pos_x += 0.3) > clist->map_w - 0.4) +		pl->pos_x = clist->map_w - 0.4; +	ft_drawmap(clist);  	return (0);  } | 
