Compare commits

..

No commits in common. "6957e843348c5a923d8ea0762c0401641d7ed879" and "4a513e9877e17e54fc7dce1383371ae1ca32a85d" have entirely different histories.

8 changed files with 79 additions and 18 deletions

View file

@ -55,7 +55,7 @@ all: $(OBJECTS) $(NAME)
-include $(DEPS) -include $(DEPS)
$(NAME): $(OBJECTS) $(NAME): $(OBJECTS)
+$(MAKE) CC=cc -C mlx/ if [[ "$$(echo $$LD_LIBRARY_PATH | grep -c minilibx)" == "0" ]]; then $(MAKE) CC=cc -C mlx/; fi
+$(MAKE) -C libft/ +$(MAKE) -C libft/
$(CC) $(CFLAGS) $(IFLAGS) $(OBJECTS) -o $(NAME) -Llibft -Lmlx -lft -lmlx -lz -lXext -lX11 -lm $(CC) $(CFLAGS) $(IFLAGS) $(OBJECTS) -o $(NAME) -Llibft -Lmlx -lft -lmlx -lz -lXext -lX11 -lm

View file

@ -1,7 +1,7 @@
NO ressources/north.xpm NO ./path_to_the_north_texture
SO ressources/north.xpm SO ./path_to_the_south_texture
WE ressources/north.xpm WE ./path_to_the_west_texture
EA ressources/north.xpm EA ./path_to_the_east_texture
F 220,100,0 F 220,100,0
C 225,30,0 C 225,30,0

View file

@ -0,0 +1,26 @@
SO ./path_to_the_south_texture
F 220,100,0
WE ./path_to_the_west_texture
C 225,30,0
NO ./path_to_the_north_texture
EA ./path_to_the_east_texture
1111111111111111111111111
1000000000110000000000001
1011000001110000000000001
1001000000000000000000001
111111111011000001110000000000001
100000000011000001110111110111111
11110111111111011100000010001
11110111111111011101010010001
11000000110101011100000010001
10000000000000001100000010001
10000000000000001101010010001
11000001110101011111011110N0111
11110111 1110101 101111010001
11111111 1111111 111111111111

View file

@ -0,0 +1,22 @@
NO ./path_to_the_north_texture
SO ./path_to_the_south_texture
WE ./path_to_the_west_texture
EA ./path_to_the_east_texture
F 220,100,0
C 225,30,0
1111111111111111111111111
100000000011000Z000000001
1011000001110000000000001
1001000000d00000000000001
111111111011000001110000000000001
10000000001100000111011111D111111
11110111111111011100000010001
11110111111111011101010010001
110000001101010111M0000010001
10000000s00000001100000010001
10000000000000001101010010001
11000001110101011111011110N01
11110111 1110101 101111010001
11111111 1111111 111111111111

View file

@ -0,0 +1,22 @@
NO ressources/north.xpm
SO ressources/south.xpm
WE ressources/west.xpm
EA ressources/east.xpm
F 220,100,0
C 225,30,0
1111111111111111111111111
1000000000110zzzzzz000001
101100000111zzzzzzz000001
10D100000000zzzzzzz000001
11111111101100000111zMzzzzz000001
100000000011000001110111110111111
11110111111111011100000010001
11110111111111011101010010001
11000000110101011100000010001
100000000000000011J0000010001
10000000000000001101010010001
11Q00001110101011111011110N0111
11110111 1110101 101111010001
11111111 1111111 111111111111

View file

@ -22,8 +22,6 @@
static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite, static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite,
int i) int i)
{ {
double tmp;
sprite->sprite_pos_x = data->sprite_list[data->sprite_order[i]]->x sprite->sprite_pos_x = data->sprite_list[data->sprite_order[i]]->x
- data->player.x; - data->player.x;
sprite->sprite_pos_y = data->sprite_list[data->sprite_order[i]]->y sprite->sprite_pos_y = data->sprite_list[data->sprite_order[i]]->y
@ -35,31 +33,24 @@ static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite,
sprite->transform_y = sprite->inv_det * (-data->player.plane_y sprite->transform_y = sprite->inv_det * (-data->player.plane_y
* sprite->sprite_pos_x * sprite->sprite_pos_x
+ data->player.plane_x * sprite->sprite_pos_y); + data->player.plane_x * sprite->sprite_pos_y);
tmp = ((WIDTH / 2) sprite->sprite_screen_x = (int)((WIDTH / 2)
* (1 + sprite->transform_x / sprite->transform_y)); * (1 + sprite->transform_x / sprite->transform_y));
if (tmp < INFINITY && tmp > -INFINITY)
sprite->sprite_screen_x = (int)tmp;
} }
static void sprite_calculate_pos_and_dist(t_cub3d_data *data, int i) static void sprite_calculate_pos_and_dist(t_cub3d_data *data, int i)
{ {
t_sprite *sprite; t_sprite *sprite;
double tmp;
sprite = data->sprite_list[i]; sprite = data->sprite_list[i];
calculate_pos_and_transform(data, sprite, i); calculate_pos_and_transform(data, sprite, i);
tmp = fabs((HEIGHT / sprite->transform_y)); sprite->sprite_height = (int)fabs((HEIGHT / sprite->transform_y));
if (tmp < INFINITY && tmp > -INFINITY)
sprite->sprite_height = (int)tmp;
sprite->sprite_draw_start_y = -sprite->sprite_height / 2 + HEIGHT / 2; sprite->sprite_draw_start_y = -sprite->sprite_height / 2 + HEIGHT / 2;
if (sprite->sprite_draw_start_y < 0) if (sprite->sprite_draw_start_y < 0)
sprite->sprite_draw_start_y = 0; sprite->sprite_draw_start_y = 0;
sprite->sprite_draw_end_y = sprite->sprite_height / 2 + HEIGHT / 2; sprite->sprite_draw_end_y = sprite->sprite_height / 2 + HEIGHT / 2;
if (sprite->sprite_draw_end_y >= HEIGHT) if (sprite->sprite_draw_end_y >= HEIGHT)
sprite->sprite_draw_end_y = HEIGHT - 1; sprite->sprite_draw_end_y = HEIGHT - 1;
tmp = fabs((HEIGHT / sprite->transform_y)); sprite->sprite_width = (int)fabs((HEIGHT / sprite->transform_y));
if (tmp < INFINITY && tmp > -INFINITY)
sprite->sprite_width = (int)tmp;
sprite->sprite_draw_start_x = -sprite->sprite_width / 2 sprite->sprite_draw_start_x = -sprite->sprite_width / 2
+ sprite->sprite_screen_x; + sprite->sprite_screen_x;
if (sprite->sprite_draw_start_x < 0) if (sprite->sprite_draw_start_x < 0)

View file

@ -2,5 +2,5 @@
for i in ./ressources/bad_maps/*; do for i in ./ressources/bad_maps/*; do
printf "testing $i...\n" printf "testing $i...\n"
./cub3D $i && printf "$i...\tFAILED (did not detect expected error)\n" || printf "$i...\tPASSED\n" ./cub3d $i && printf "$i...\tFAILED (did not detect expected error)\n" || printf "$i...\tPASSED\n"
done done