-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
2,695 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ignore object files in source folders | ||
srcs/*.o | ||
libft/srcs/*/*.o | ||
libft/libft.a | ||
wolf3d | ||
**.DS_Store | ||
.VScode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# **************************************************************************** # | ||
# # | ||
# ::: :::::::: # | ||
# Makefile :+: :+: :+: # | ||
# +:+ +:+ +:+ # | ||
# By: tmaluh <[email protected]> +#+ +:+ +#+ # | ||
# +#+#+#+#+#+ +#+ # | ||
# Created: 2019/02/06 14:43:13 by tmaluh #+# #+# # | ||
# Updated: 2019/02/06 15:02:38 by tmaluh ### ########.fr # | ||
# # | ||
# **************************************************************************** # | ||
|
||
NAME = wolf3d | ||
|
||
UNAME_S := $(shell uname -s) | ||
ifeq ($(UNAME_S),Linux) | ||
MLXFLAGS := -L /usr/local/lib -I /usr/local/lib -lmlx -lXext -lX11 -lm | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
MLXFLAGS := -L /usr/local/lib -lmlx -lm -framework OpenGL -framework AppKit | ||
endif | ||
|
||
CC = gcc -march=native | ||
CFLAGS = -Wall -Wextra -Werror -Ofast | ||
|
||
SRC = srcs/main.c srcs/wolf_init.c srcs/wolf_key_hooks.c srcs/wolf_free.c | ||
|
||
OBJ = $(SRC:.c=.o) | ||
|
||
LIBFT = libft/libft.a | ||
LMAKE = make -C libft | ||
|
||
WHITE=\033[0m | ||
GREEN=\033[32m | ||
RED=\033[31m | ||
|
||
DEL = rm -rf | ||
|
||
all: $(NAME) | ||
|
||
$(OBJ): %.o: %.c | ||
@echo -n '+' | ||
@$(CC) -c $(CFLAGS) $< -o $@ | ||
|
||
$(LIBFT): | ||
@$(LMAKE) | ||
|
||
$(NAME): $(LIBFT) $(OBJ) | ||
@$(CC) $(OBJ) $(MLXFLAGS) $(LIBFT) -o $(NAME) | ||
@echo "> $(NAME) $(GREEN)Compiled$(WHITE)" | ||
|
||
del: | ||
@$(DEL) $(OBJ) | ||
|
||
clean: | ||
@$(DEL) $(OBJ) | ||
@$(LMAKE) clean | ||
|
||
fclean: clean | ||
@$(LMAKE) fclean | ||
@$(DEL) $(NAME) | ||
@echo "$(RED)deleted$(WHITE): ./wolf3d" | ||
|
||
re: fclean all | ||
|
||
.PHONY: all fclean clean re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tmaluh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* linux_keys.h :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2018/12/14 12:46:50 by tmaluh #+# #+# */ | ||
/* Updated: 2019/01/17 17:15:41 by tmaluh ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef LINUX_KEYS_H | ||
# define LINUX_KEYS_H | ||
|
||
# define KEY_PRESSED 2 | ||
# define KEY_RELEASE 3 | ||
|
||
# define ESC 65307 | ||
|
||
# define KEY_C 99 | ||
|
||
# define KEY_W 119 | ||
# define KEY_A 97 | ||
# define KEY_S 115 | ||
# define KEY_D 100 | ||
|
||
# define KEY_T 116 | ||
# define KEY_G 103 | ||
# define KEY_Y 121 | ||
# define KEY_H 104 | ||
|
||
# define KEY_I 105 | ||
# define KEY_P 112 | ||
|
||
# define ARROW_UP 65362 | ||
# define ARROW_DOWN 65364 | ||
# define ARROW_RIGHT 65363 | ||
# define ARROW_LEFT 65361 | ||
|
||
# define PLUS_NUMPAD 65451 | ||
# define PLUS_KEYBOARD 61 | ||
# define MINUS_NUMPAD 65453 | ||
# define MINUS_KEYBOARD 45 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* macos_keys.h :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2018/12/14 12:46:42 by tmaluh #+# #+# */ | ||
/* Updated: 2019/01/17 17:15:45 by tmaluh ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef MACOS_KEYS_H | ||
# define MACOS_KEYS_H | ||
|
||
# define KEY_PRESSED 2 | ||
# define KEY_RELEASE 2 | ||
|
||
# define ESC 53 | ||
|
||
# define KEY_C 8 | ||
|
||
# define KEY_W 13 | ||
# define KEY_A 0 | ||
# define KEY_S 1 | ||
# define KEY_D 2 | ||
|
||
# define KEY_T 17 | ||
# define KEY_G 5 | ||
# define KEY_Y 16 | ||
# define KEY_H 4 | ||
|
||
# define KEY_I 34 | ||
# define KEY_P 35 | ||
|
||
# define ARROW_UP 126 | ||
# define ARROW_DOWN 125 | ||
# define ARROW_RIGHT 124 | ||
# define ARROW_LEFT 123 | ||
|
||
# define PLUS_NUMPAD 69 | ||
# define PLUS_KEYBOARD 24 | ||
# define MINUS_NUMPAD 78 | ||
# define MINUS_KEYBOARD 27 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* wolf3d.h :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/02/06 14:30:10 by tmaluh #+# #+# */ | ||
/* Updated: 2019/02/06 15:09:09 by tmaluh ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef WOLF3D_H | ||
# define WOLF3D_H | ||
|
||
# ifdef __APPLE__ | ||
# include "macos_keys.h" | ||
# endif | ||
|
||
# ifdef __linux__ | ||
# include "linux_keys.h" | ||
# endif | ||
|
||
# include "wolf3d_defines.h" | ||
# include "wolf3d_errno.h" | ||
# include "../libft/includes/libft.h" | ||
# include <fcntl.h> | ||
# include <stdio.h> | ||
# include <math.h> | ||
# include <mlx.h> | ||
|
||
enum e_bool {false, true} __attribute__((packed)); | ||
|
||
typedef struct s_point | ||
{ | ||
short y; | ||
short x; | ||
} t_p; | ||
|
||
typedef struct s_fpoint | ||
{ | ||
float y; | ||
float x; | ||
} t_fp; | ||
|
||
_FPOINT; | ||
_POINT; | ||
_BOOL; | ||
_IARR; | ||
|
||
typedef struct s_isrender | ||
{ | ||
bool is_render; | ||
} t_isr; | ||
|
||
typedef struct s_mlx | ||
{ | ||
pvoid mlx; | ||
pvoid win; | ||
pvoid img; | ||
iarr screen; | ||
} t_mlx; | ||
|
||
typedef struct s_fdf_environment | ||
{ | ||
t_mlx *mlx; | ||
t_isr *isr; | ||
} t_env; | ||
|
||
bool wolf_init(t_env *env); | ||
|
||
int wolf_key_hooks(int key, t_env *env); | ||
int wolf_killwindow_hook(t_env *env); | ||
|
||
void wolf_free(t_env *env); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* wolf3d_defines.h :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/02/06 14:34:31 by tmaluh #+# #+# */ | ||
/* Updated: 2019/02/06 15:09:33 by tmaluh ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef WOLF3D_DEFINES_H | ||
# define WOLF3D_DEFINES_H | ||
|
||
# define WIN_X 2000 | ||
# define WIN_Y 1000 | ||
# define WIN_TITTLE "Wolfenstein 3D" | ||
|
||
# define WIN_EXT 17 | ||
# define WIN_EXTM (1L << 17) | ||
|
||
# define MOUSE_MASK 0 | ||
# define MOUSE_DOWN 4 | ||
# define MOUSE_UP 5 | ||
# define MOUSE_MOVE 6 | ||
|
||
# define MLEFT_BUTTON 1 | ||
# define MRIGHT_BUTTON 2 | ||
# define MTHIRD_BUTTON 3 | ||
# define MSCROLL_DOWN 4 | ||
# define MSCROLL_UPS 5 | ||
# define MSCROLL_LEFT 6 | ||
# define MSCROLL_RIGHT 7 | ||
|
||
# define PI 3.141592 | ||
|
||
# define INT_MAX 2147483647 | ||
# define INT_MIN (-INT_MAX-1) | ||
|
||
# define SHIFT_INC 15 | ||
|
||
# define ROT_MIN 0.0 | ||
# define ROT_INC 5.0 | ||
# define ROT_MAX 360.0 | ||
|
||
# define ZOOM_INC 1 | ||
# define ZOOM_MIN 1 | ||
# define ZOOM_DEF 15 | ||
# define ZOOM_MAX 127 | ||
|
||
# define _MSG(msg) ft_putstr(msg); | ||
# define _MSGN(msg) ft_putendl(msg); | ||
# define _NOTIS(msg, ex, do, ret) if (!(ex)) {_MSGN(msg);do;return (ret);} | ||
# define _NOTIS_N(ex) if (!(ex)) return (NULL) | ||
# define _NOTIS_F(ex) if (!(ex)) return (false) | ||
|
||
# define _ISARGS(ac, av) {--ac;++av;_NOTIS(E_USAGE, !(ac != 1), exit(-1), 0);} | ||
|
||
# define _ABS(var) ((var) < 0) ? -(var) : (var) | ||
# define _RAD(deg) (((deg) * PI) / 180.0) | ||
# define _COSR(angle) cos(_RAD(angle)) | ||
# define _SINR(angle) sin(_RAD(angle)) | ||
|
||
# define _BOOL typedef enum e_bool bool | ||
# define _IARR typedef int* iarr | ||
# define _POINT typedef t_p point | ||
# define _FPOINT typedef t_fp fpoint | ||
|
||
# define MPTR env->mlx->mlx | ||
# define WPTR env->mlx->win | ||
# define IPTR env->mlx->img | ||
# define SPTR env->mlx->screen | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* wolf3d_errno.h :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: tmaluh <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/02/06 14:39:47 by tmaluh #+# #+# */ | ||
/* Updated: 2019/02/06 14:40:21 by tmaluh ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef WOLF3D_ERRNO_H | ||
# define WOLF3D_ERRNO_H | ||
|
||
# define E_USAGE "Usage: ./wolf3d <map_name>.w3d" | ||
# define E_ALLOC "Where is memory, pal ?" | ||
# define E_FILER "File reading error" | ||
|
||
# define E_EMAP "\tERROR: Empty map \\ " | ||
# define E_IMAP "\tERROR: Invalid map \\ " | ||
# define E_HEX "\tERROR: Invalid HEX code or you put black color \\ " | ||
|
||
#endif |
Oops, something went wrong.