diff --git a/graphics_utils.c b/graphics_utils.c index 014789d..ed2a07e 100644 --- a/graphics_utils.c +++ b/graphics_utils.c @@ -6,13 +6,31 @@ /* By: jbadaire +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/03 12:56:12 by jbadaire #+# #+# */ -/* Updated: 2023/10/05 15:25:18 by jbadaire ### ########.fr */ +/* Updated: 2023/10/05 19:26:44 by jbadaire ### ########.fr */ /* */ /* ************************************************************************** */ #include "so_long.h" #include "minilibx-linux/mlx.h" +t_texture *load_textures(void *mlx) +{ + t_texture *list; + + list = malloc(sizeof (t_texture *) * 5); + if(!list) + return (NULL); + + ft_lstadd_texture(&list, ft_lstnew(load_texture("./textures/wall.xpm", mlx))); + ft_lstadd_texture(&list, ft_lstnew(load_texture("./textures/grass.xpm", mlx))); + ft_lstadd_texture(&list, ft_lstnew(load_texture("./textures/player.xpm", mlx))); + ft_lstadd_texture(&list, ft_lstnew(load_texture("./textures/collectible.xpm", mlx))); + ft_lstadd_texture(&list, ft_lstnew(load_texture("./textures/exit.xpm", mlx))); + + return (list); +} + + void *load_texture(char *path, void *mlx) { void *img; @@ -48,3 +66,22 @@ void destroy_texture() { } + +void ft_lstadd_texture(t_list **lst, t_list *new) +{ + new->next = *lst; + *lst = new; +} + +t_texture_list *ft_newtexture(char *name, void *content) +{ + t_texture_list *list; + + list = malloc(sizeof (t_list)); + if (!list) + return (0); + list->name = name; + list->texture = content; + list->next = NULL; + return (list); +} diff --git a/main.c b/main.c index 23f6496..88b3a68 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: jbadaire +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/02 16:19:55 by jbadaire #+# #+# */ -/* Updated: 2023/10/05 16:31:39 by jbadaire ### ########.fr */ +/* Updated: 2023/10/05 17:08:40 by jbadaire ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/player.c b/player.c index 309ce7e..dbdc731 100644 --- a/player.c +++ b/player.c @@ -31,7 +31,6 @@ int on_player_move(int keycode, t_world *world) //d = 100 printf("\nPRINT: %d", keycode); - if(!can_move(keycode, world)) return -1; diff --git a/so_long.h b/so_long.h index ed83e75..047cd5f 100644 --- a/so_long.h +++ b/so_long.h @@ -6,7 +6,7 @@ /* By: jbadaire +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/10/02 17:59:52 by jbadaire #+# #+# */ -/* Updated: 2023/10/05 16:30:22 by jbadaire ### ########.fr */ +/* Updated: 2023/10/05 19:29:00 by jbadaire ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,6 +43,13 @@ typedef struct s_world t_player *player; } t_world; +typedef struct s_texture_list +{ + void *name; + void *texture; + struct s_texture_list *next; +} t_texture_list; + t_world load_map(int fd, char *path); t_boolean is_horizontal_rectangle(t_world world); t_boolean is_vertical_rectangle(t_world world); @@ -75,6 +82,6 @@ t_location clone_location(t_location location); t_location create_location(int x, int y); t_collectible *get_collectible_at(t_world world, t_location location); - +void ft_lstadd_texture(t_list **lst, t_list *new); #endif