-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,31 @@ | |
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* 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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* 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 */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: jbadaire <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* 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 |