Skip to content

Commit

Permalink
Cleaned & Added Libft Lib and GNL
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Simeonov committed Mar 21, 2022
1 parent b9e11c5 commit baf7c47
Show file tree
Hide file tree
Showing 26 changed files with 123 additions and 19,042 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NAME = so_long

SRC = so_long.c utils.c get_next_line.c checkers.c create_destroy_map.c hooks_and_rules.c utils_linked_lists.c
SRC = checkers.c checkers2.c create_destroy_map.c hooks_and_rules.c so_long.c utils_linked_lists.c utils.c

OBJ = $(SRC:.c=.o)

Expand All @@ -16,14 +16,16 @@ $(%.o): $(%.c)
$(CC) $(FLAGS) -Imlx -c $< -o $@

$(NAME): $(OBJ)
$(CC) $(OBJ) -Lmlx -lmlx -framework OpenGL -framework AppKit -o $(NAME)
make -C libft/
$(CC) $(OBJ) libft/libft.a -Lmlx -lmlx -framework OpenGL -framework AppKit -o $(NAME)

clean:
$(RM) *.o
make clean -C mlx/
make clean -C libft/

fclean: clean
$(RM) $(NAME)
make fclean -C libft/

re: fclean all

Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ DONE - check that the Map is a Rectangle
DONE - check that a P, C, and E exists
DONE - check that there are Walls (1s) surrounding the Map
DONE - check that there are not any other Characters except P,C,E, 1 and 0;
3. Initialize MLX, Creating the Window
-
4. Designing and Finding the Images
5. Converting Images to .xml
6. Display the Pixel Art on the corresponding Map Coordinates
7. Mapping the Keys to the Game
8. Free Allocated Memmory
DONE 3. Initialize MLX, Creating the Window
DONE 4. Designing and Finding the Images
DONE 5. Converting Images to .xml
DONE 6. Display the Pixel Art on the corresponding Map Coordinates
DONE 7. Mapping the Keys to the Game
DONE 8. Create the Rules
DONE 9. Free Allocated Memmory


TO DO
Link Get_next_line through Makefile
43 changes: 13 additions & 30 deletions checkers.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,25 @@
/* By: vsimeono <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/17 13:44:38 by vsimeono #+# #+# */
/* Updated: 2022/03/17 15:58:07 by vsimeono ### ########.fr */
/* Updated: 2022/03/21 15:42:19 by vsimeono ### ########.fr */
/* */
/* ************************************************************************** */

#include "so_long.h"


/* Checking if P, E, C is in Map */
int check_P_E_C_in_map(t_long *arch, t_list **lines)
int check_p_e_c_in_map(t_long *arch, t_list **lines)
{
t_list *temp;
int i;
int len_line;
int flag[255];

temp = *lines;
len_line = ft_strlen_line(lines);
i = 0;
while (i > 255)
{
flag[i] = 0;
i++;
}
flag[i++] = 0;
while (temp->next != NULL)
{
if (ft_strchr(temp->line, 'P'))
Expand All @@ -45,9 +41,6 @@ int check_P_E_C_in_map(t_long *arch, t_list **lines)
{
flag[67] = 1;
arch->collect++;
printf("%d\n", arch->collect);
printf("%d\n", arch->collect);
printf("%d\n", arch->collected);
}
temp = temp->next;
}
Expand All @@ -57,20 +50,22 @@ int check_P_E_C_in_map(t_long *arch, t_list **lines)
}

/* Check that there are not any other Characters except P,C,E, 1 and 0 */
int is_only__P_C_E_1_0_in_map(t_list **lines)
int is_p_c_e_1_0(t_list **lines)
{
t_list *temp;
int i;
int len_line;

temp = (*lines);
len_line = ft_strlen_line(lines);
while (temp->next != NULL)
{
i = 0;
while (i < len_line)
{
if (temp->line[i] != '0' && temp->line[i] != '1' && temp->line[i] != 'P' && temp->line[i] != 'E' && temp->line[i] != 'C' && temp->line[i] != '\n')
if (temp->line[i] != '0' && temp->line[i] != '1' && \
temp->line[i] != 'P' && temp->line[i] != 'E' && \
temp->line[i] != 'C' && temp->line[i] != '\n')
return (0);
i++;
}
Expand All @@ -80,7 +75,7 @@ int is_only__P_C_E_1_0_in_map(t_list **lines)
}

/* Checking the Length of the Lines are the Same */
int is_length_of_lines_the_same(t_list **lines)
int is_length(t_list **lines)
{
t_list *temp;
int len_line;
Expand All @@ -97,10 +92,10 @@ int is_length_of_lines_the_same(t_list **lines)
}

/* Checking if first Line and Last Line is Made from 1s */
int is_first_and_last_line_is_one(t_list **lines)
int is_first_last_line(t_list **lines)
{
t_list *temp;

temp = (*lines);
if (!ft_strchr_first_line(temp->line, '1'))
return (0);
Expand All @@ -112,7 +107,7 @@ int is_first_and_last_line_is_one(t_list **lines)
}

/* Check if First Char and Last Char is 1 */
int is_first_char_and_last_char_one(t_list **lines)
int is_first_last_char(t_list **lines)
{
t_list *temp;
int len_line;
Expand All @@ -132,15 +127,3 @@ int is_first_char_and_last_char_one(t_list **lines)
}
return (1);
}

/* Checking if the Map has Extension .ber*/
int is_map(char *argv)
{
int len;

len = ft_strlen(argv);
if (argv[len - 4] == '.' && argv[len - 3] == 'b' && \
argv[len - 2] == 'e' && argv[len - 1] == 'r')
return (1);
return (0);
}
25 changes: 25 additions & 0 deletions checkers2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* checkers2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vsimeono <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/21 15:03:09 by vsimeono #+# #+# */
/* Updated: 2022/03/21 15:03:50 by vsimeono ### ########.fr */
/* */
/* ************************************************************************** */

#include "so_long.h"

/* Checking if the Map has Extension .ber*/
int is_map(char *argv)
{
int len;

len = ft_strlen(argv);
if (argv[len - 4] == '.' && argv[len - 3] == 'b' && \
argv[len - 2] == 'e' && argv[len - 1] == 'r')
return (1);
return (0);
}
28 changes: 18 additions & 10 deletions create_destroy_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: vsimeono <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/17 14:04:00 by vsimeono #+# #+# */
/* Updated: 2022/03/17 14:04:31 by vsimeono ### ########.fr */
/* Updated: 2022/03/21 15:30:16 by vsimeono ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -15,7 +15,7 @@
int loop(t_long *arch)
{
char *moves;

moves = ft_itoa(arch->moves);
mlx_string_put(arch->mlx, arch->mlx_win, 30, 30, 0xffff00, moves);
return (0);
Expand Down Expand Up @@ -57,25 +57,33 @@ void create_visual_map(t_long *arch)
}
}

/* Loading Pictures as the Pixels for the Graphical Map according to their Corresponding Lettter or Number */
/* Loading Pictures as the Pixels for the Graphical Map
according to their Corresponding Lettter or Number */
void load_assests(t_long *arch, char c, int x, int y)
{
if (c == '1')
arch->img.img = mlx_xpm_file_to_image(arch->mlx, "./data/red_walls.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, \
"./data/red_walls.xpm", &arch->img.size_x, &arch->img.size_y);
else if (c == 'P')
{
arch->img.img = mlx_xpm_file_to_image(arch->mlx, "./data/space.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, "./data/sun_resized.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, \
"./data/space.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, \
"./data/sun_resized.xpm", &arch->img.size_x, &arch->img.size_y);
}
else if (c == 'E')
arch->img.img = mlx_xpm_file_to_image(arch->mlx, "./data/exit_x.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, \
"./data/exit_x.xpm", &arch->img.size_x, &arch->img.size_y);
else if (c == 'C')
{
arch->img.img = mlx_xpm_file_to_image(arch->mlx, "./data/space.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, "./data/heart.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, \
"./data/space.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, \
"./data/heart.xpm", &arch->img.size_x, &arch->img.size_y);
}
else
arch->img.img = mlx_xpm_file_to_image(arch->mlx, "./data/space.xpm", &arch->img.size_x, &arch->img.size_y);
arch->img.img = mlx_xpm_file_to_image(arch->mlx, \
"./data/space.xpm", &arch->img.size_x, &arch->img.size_y);
mlx_put_image_to_window(arch->mlx, arch->mlx_win, arch->img.img, x, y);
mlx_destroy_image(arch->mlx, arch->img.img);
}
Binary file modified data/.DS_Store
Binary file not shown.
Loading

0 comments on commit baf7c47

Please sign in to comment.