Skip to content

Commit

Permalink
merged with new parsing standard
Browse files Browse the repository at this point in the history
Former-commit-id: de2e490
  • Loading branch information
Kristina Dancy committed Sep 6, 2022
2 parents 0891771 + f5a8094 commit 94858f8
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 114 deletions.
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/cub3d.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ INCDIR = inc/
SNDLIB = cute_sound/cute_sound.o

UNAME = $(shell uname -s)

ifeq ($(UNAME), Darwin)
MLXFLAGS = -Lmlx -lmlx -framework OpenGL -framework AppKit
MLX = mlx
SNDLIB += cute_sound/SDL2
endif

ifeq ($(UNAME), Linux)
MLXFLAGS = -Lmlx_linux -lmlx -Imlx_linux -lXext -lX11 -lm -lz
MLX = mlx_linux
Expand Down
Binary file modified assets/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions assets/sus_sped_up.wav.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f713a9b000866e6686dd18586aed94595866f575
5 changes: 0 additions & 5 deletions assets/wah-goodman/convert.sh

This file was deleted.

1 change: 0 additions & 1 deletion cub3d.REMOVED.git-id

This file was deleted.

10 changes: 7 additions & 3 deletions inc/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# define PROJ_NAME "Cub3d"
# define WIN_WIDTH 1920
# define WIN_HEIGHT 1026
// # define WIN_WIDTH 1280
// # define WIN_HEIGHT 720
# define MAP_GRID_SIZE 32
# define TEXTURE_SIZE 192
# define MAX_RENDER_DISTANCE 5000
Expand All @@ -22,12 +24,14 @@
# define AIM_SIZE 4
# define AIM_COLOR 0xFF0000
# define MAX_TEXTURES 4
# define MAX_WALL_CHARS 4
// # define MAX_WALL_CHARS 10
// # define MAX_WALL_CHARS 4
# define MAX_WALL_CHARS 10

# define WALL_CHARS "12D3456789"
// # define WALL_CHARS "1D23456789"
# define WALL_CHARS "123456789D"
# define CARDINAL_POINTS "NSWE"

# define WALL_PREFIX "W"
# ifdef __APPLE__
enum e_keys
{
Expand Down
10 changes: 6 additions & 4 deletions inc/cub3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ typedef struct s_map
{
char **map;
t_vector map_size;
t_list *texture_list[MAX_TEXTURES];
t_list *img_list[MAX_TEXTURES];
t_list *texture_list[MAX_WALL_CHARS];
t_list *img_list[MAX_WALL_CHARS];
unsigned list_size;
// char *NO;
// char *SO;
Expand Down Expand Up @@ -117,7 +117,7 @@ typedef struct game
float fade;
int color;
} *column;
t_img textures[MAX_TEXTURES];
t_img textures[MAX_WALL_CHARS];

struct s_audio
{
Expand Down Expand Up @@ -190,7 +190,8 @@ int ft_strrchr_int(char *line, int chr);
t_map *create_empty_map(void);
int is_wall(char c);
int ft_arraylen(void **arr);
t_list *get_textures_list(int fd, char *prefix, char **line_ret);
int get_string_index(char *str, char c);
void get_textures_list(t_map* map, int fd, char **line);
// char *get_textures_list(int fd, char *prefix, t_list **lst);
//controller.c
int close_hook(t_game *game);
Expand Down Expand Up @@ -228,6 +229,7 @@ void open_door(t_game *game);
// time
t_ull get_time(void);
void init_time(t_game *game);
void wait_milliseconds(int milliseconds);

void draw_texture_set(t_game *game, struct s_column *column);
#endif
5 changes: 3 additions & 2 deletions maps/e1m1 copy.cub
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,10 @@ WE ./assets/sus64xpm/sus32-0.xpm
EA0 ./assets/sus64xpm/sus32-0.xpm
EA1 ./assets/sus64xpm/sus32-1.xpm

F 110,110,10

C 111,110,10
F 11,57,37

C 94,110,187
111111111111111
111111 110000001000011
100001 111111111111000001000000011111
Expand Down
46 changes: 34 additions & 12 deletions maps/e1m1bonus.cub
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
10 ./assets/sus64xpm/sus32-0.xpm
11 ./assets/sus64xpm/sus32-1.xpm
12 ./assets/sus64xpm/sus32-2.xpm
13 ./assets/sus64xpm/sus32-3.xpm
14 ./assets/sus64xpm/sus32-4.xpm
15 ./assets/sus64xpm/sus32-5.xpm
W1 ./assets/sussy_stickmin/sussy-00.xpm
./assets/sussy_stickmin/sussy-01.xpm
./assets/sussy_stickmin/sussy-02.xpm
./assets/sussy_stickmin/sussy-03.xpm
./assets/sussy_stickmin/sussy-04.xpm
./assets/sussy_stickmin/sussy-05.xpm
./assets/sussy_stickmin/sussy-06.xpm
./assets/sussy_stickmin/sussy-07.xpm
./assets/sussy_stickmin/sussy-08.xpm
./assets/sussy_stickmin/sussy-09.xpm
./assets/sussy_stickmin/sussy-10.xpm
./assets/sussy_stickmin/sussy-11.xpm
./assets/sussy_stickmin/sussy-12.xpm
./assets/sussy_stickmin/sussy-13.xpm
./assets/sussy_stickmin/sussy-14.xpm
./assets/sussy_stickmin/sussy-15.xpm
./assets/sussy_stickmin/sussy-16.xpm
./assets/sussy_stickmin/sussy-17.xpm

F 110,110,10
W2 ./assets/wah-goodman/wah102.xpm
W3 ./assets/wah-goodman/wah103.xpm
W4 ./assets/wah-goodman/wah104.xpm
W5 ./assets/wah-goodman/wah105.xpm
W6 ./assets/wah-goodman/wah106.xpm
W7 ./assets/wah-goodman/wah107.xpm
W8 ./assets/wah-goodman/wah108.xpm
W9 ./assets/wah-goodman/wah109.xpm

C 111,110,10
WD ./assets/wah-goodman/wah001.xpm
./assets/wah-goodman/wah002.xpm
F 217,242,253
C 178,229,251
111111111111111
111111 110000001000011
100001 111111111111000001000000011111
Expand All @@ -30,7 +52,7 @@ C 111,110,10
1000001010101 1111 10101
1000100010001 10001
1000111111011111 11011 1111111111
1010110000000001 11111110001111111 1000000001
1010110000000001 111D1110001111111 1000000001
1000110100000101 11000000000000011 1000000001
1000110010001001 1000000000000000111111111111000000001
1000010000000001 1000000000000000000000000000000000001
Expand All @@ -42,16 +64,16 @@ C 111,110,10
1010111111011111 1000001 1001 1000000001
10001 10001 10001 1001 11111111
1000111110001 10101 1001
1000110110001 10001 1001 111111111
1000110110001 10001 1001 111D11111
1000001010101 10001 100010000000001
1000100010001 10001 1000D0000000001
1010111110001 10101 10001000E000001
1000111110001111111111111 10001 1000D0000000011
100000000000000001000000111 10001 111110000000101
100000100000001001000000101 10001 111111111
100000000000000001000000111 10101
1111111111111111110111111 10001
111001000001 111111000111111
111111111111111111011111111 10001
111001000001 1111111000111111
101001001011 100000000000001
11100000111 100001010101001
1101111 100000000000001
Expand Down
1 change: 1 addition & 0 deletions maps/e1m1newparsing.cub.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
234865f49e06d11a32a1d739f3f5d091a2ffceaa
10 changes: 6 additions & 4 deletions src/border_checking.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int get_map_width(char **map)
{
ft_putendl_fd(*map, 1);
if (max_width < ft_strrchr_int(*map, '1'))
max_width = ft_strrchr_int(*map, '1');
max_width = ft_strrchr_int(*map, '1'); // change wall to WALL_CHARS
++map;
}
return (max_width);
Expand Down Expand Up @@ -54,7 +54,7 @@ int find_player(t_map *map, char *line, t_list *lst)

int is_wall(char c)
{
return (c == '1' || c == 'D');
return (ft_strchr(WALL_CHARS, c) != NULL);
}

int check_enclosure(t_map *map, t_vector vec)
Expand All @@ -64,10 +64,12 @@ int check_enclosure(t_map *map, t_vector vec)
if (vec.x == 0 || vec.x == map->map_size.x - 1 || vec.y == 0
|| vec.y == map->map_size.y - 1)
return (1);
return (map->map[vec.y - 1][vec.x] == ' '
if (map->map[vec.y - 1][vec.x] == ' '
|| map->map[vec.y + 1][vec.x] == ' '
|| map->map[vec.y][vec.x - 1] == ' '
|| map->map[vec.y][vec.x + 1] == ' ');
|| map->map[vec.y][vec.x + 1] == ' ')
return 1;
return 0;
}

int is_enclosed(t_map *args)
Expand Down
10 changes: 5 additions & 5 deletions src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ void open_door(t_game *game)

to_change = NULL;
if (PI / 4 <= angle && angle <= 3 * PI / 4 && ft_tolower(game->grid
[y - 1][x]) == 'd')
to_change = game->grid[y - 1] + x;
[y + 1][x]) == 'd')
to_change = game->grid[y + 1] + x;
else if (3 * PI / 4 <= angle && angle <= 5 * PI / 4 && ft_tolower(game->grid
[y][x - 1]) == 'd')
to_change = game->grid[y] + x - 1;
else if (5 * PI / 4 <= angle && angle <= 7 * PI / 4 && ft_tolower(game->grid
[y + 1][x]) == 'd')
to_change = game->grid[y + 1] + x;
[y - 1][x]) == 'd')
to_change = game->grid[y - 1] + x;
else if ((7 * PI / 4 <= angle || angle <= PI / 4) && ft_tolower(game->grid
[y][x + 1]) == 'd')
to_change = game->grid[y] + x + 1;
Expand Down Expand Up @@ -200,7 +200,7 @@ void change_textures(t_game *game)
if (frames_to_move)
{
index = -1;
while (++index < MAX_TEXTURES)
while (++index < MAX_WALL_CHARS)
{
counter = -1;
while (++counter < frames_to_move)
Expand Down
8 changes: 4 additions & 4 deletions src/ft_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
t_map *create_empty_map()
{
t_map *map;
int counter;

counter = -1;
map = malloc(sizeof(*map));
if (!map)
return (NULL);
map->map = NULL;
while (++counter < MAX_WALL_CHARS)
map->texture_list[counter] = NULL;
map->C = 0;
map->F = 0;
map->texture_list[0] = NULL;
map->texture_list[1] = NULL;
map->texture_list[2] = NULL;
map->texture_list[3] = NULL;
map->player_coords.x = BAD_COORD;
map->player_coords.y = BAD_COORD;
map->last_collision.x = BAD_COORD;
Expand Down
9 changes: 2 additions & 7 deletions src/input_manip.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ char *crop_prefix(char* line, char *prefix)
char *new_line;
char *begin;

if (ft_strncmp(line, prefix, ft_strlen(prefix)))
if (!line || ft_strncmp(line, prefix, ft_strlen(prefix)))
{
free(line);
return (NULL);
}
begin = line + ft_strlen(prefix);
while ((ft_isdigit(*begin)))
while (get_string_index(WALL_CHARS, *begin) != -1)
++begin;
while (*begin == ' ' || *begin == '\t')
++begin;
Expand All @@ -36,11 +36,6 @@ char *skip_empty_lines(int fd)
return (line);
}

char *get_texture(int fd)
{
return (skip_empty_lines(fd)); //TODO: ??
}

int convert_rgb(char *line)
{
char **rgb_values;
Expand Down
Loading

0 comments on commit 94858f8

Please sign in to comment.