mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 09:58:09 +01:00
Compare commits
4 commits
4a513e9877
...
6957e84334
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6957e84334 | ||
|
|
ae66d62f75 | ||
|
|
5d1f915a77 | ||
|
|
d78e358b82 |
8 changed files with 18 additions and 79 deletions
2
Makefile
2
Makefile
|
|
@ -55,7 +55,7 @@ all: $(OBJECTS) $(NAME)
|
|||
-include $(DEPS)
|
||||
|
||||
$(NAME): $(OBJECTS)
|
||||
if [[ "$$(echo $$LD_LIBRARY_PATH | grep -c minilibx)" == "0" ]]; then $(MAKE) CC=cc -C mlx/; fi
|
||||
+$(MAKE) CC=cc -C mlx/
|
||||
+$(MAKE) -C libft/
|
||||
$(CC) $(CFLAGS) $(IFLAGS) $(OBJECTS) -o $(NAME) -Llibft -Lmlx -lft -lmlx -lz -lXext -lX11 -lm
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
NO ./path_to_the_north_texture
|
||||
SO ./path_to_the_south_texture
|
||||
WE ./path_to_the_west_texture
|
||||
EA ./path_to_the_east_texture
|
||||
NO ressources/north.xpm
|
||||
SO ressources/north.xpm
|
||||
WE ressources/north.xpm
|
||||
EA ressources/north.xpm
|
||||
|
||||
F 220,100,0
|
||||
C 225,30,0
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
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
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
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
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
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
|
||||
|
|
@ -22,6 +22,8 @@
|
|||
static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite,
|
||||
int i)
|
||||
{
|
||||
double tmp;
|
||||
|
||||
sprite->sprite_pos_x = data->sprite_list[data->sprite_order[i]]->x
|
||||
- data->player.x;
|
||||
sprite->sprite_pos_y = data->sprite_list[data->sprite_order[i]]->y
|
||||
|
|
@ -33,24 +35,31 @@ static void calculate_pos_and_transform(t_cub3d_data *data, t_sprite *sprite,
|
|||
sprite->transform_y = sprite->inv_det * (-data->player.plane_y
|
||||
* sprite->sprite_pos_x
|
||||
+ data->player.plane_x * sprite->sprite_pos_y);
|
||||
sprite->sprite_screen_x = (int)((WIDTH / 2)
|
||||
tmp = ((WIDTH / 2)
|
||||
* (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)
|
||||
{
|
||||
t_sprite *sprite;
|
||||
double tmp;
|
||||
|
||||
sprite = data->sprite_list[i];
|
||||
calculate_pos_and_transform(data, sprite, i);
|
||||
sprite->sprite_height = (int)fabs((HEIGHT / sprite->transform_y));
|
||||
tmp = 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;
|
||||
if (sprite->sprite_draw_start_y < 0)
|
||||
sprite->sprite_draw_start_y = 0;
|
||||
sprite->sprite_draw_end_y = sprite->sprite_height / 2 + HEIGHT / 2;
|
||||
if (sprite->sprite_draw_end_y >= HEIGHT)
|
||||
sprite->sprite_draw_end_y = HEIGHT - 1;
|
||||
sprite->sprite_width = (int)fabs((HEIGHT / sprite->transform_y));
|
||||
tmp = 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_screen_x;
|
||||
if (sprite->sprite_draw_start_x < 0)
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
for i in ./ressources/bad_maps/*; do
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue