Skip to content

Commit

Permalink
start texture struct
Browse files Browse the repository at this point in the history
  • Loading branch information
vSKAH committed Oct 5, 2023
1 parent 17eba2d commit 66a97f4
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
39 changes: 38 additions & 1 deletion graphics_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/* */
/* ************************************************************************** */

Expand Down
1 change: 0 additions & 1 deletion player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 9 additions & 2 deletions so_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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

0 comments on commit 66a97f4

Please sign in to comment.