#include <stdio.h>
#include <mlx.h>
#include “so_long.h”
#include “libft.h”
typedef struct s_game
{
void *connection_id;
void *win;
void *img_space;
void *img_wall;
void *img_player;
void *img_colect;
void *img_exit;
int img_width;
int img_height;
} t_game;
int map_width;
int map_height;
static void ft_window_size(char **map)
{
int i;
map_width = ft_strlen(map[0]) * 50;
i = 0;
while (map[i] != ‘\0’)
i++;
map_height = i * 50;
}
int main(int argc, char **argv)
{
t_game *shit;
t_game ok;
int y = 0;
int x;
char **map;
ok.connection_id = mlx_init();
map = ft_read_map(argv[1]);
shit->img_space = mlx_xpm_file_to_image(ok.connection_id, "space.xpm", &shit->img_width, &shit->img_height);
shit->img_wall = mlx_xpm_file_to_image(ok.connection_id, "wall.xpm", &shit->img_width, &shit->img_height);
shit->img_player = mlx_xpm_file_to_image(ok.connection_id, "player.xpm", &shit->img_width, &shit->img_height);
shit->img_colect = mlx_xpm_file_to_image(ok.connection_id, "collector.xpm", &shit->img_width, &shit->img_height);
shit->img_exit = mlx_xpm_file_to_image(ok.connection_id, "exit.xpm", &shit->img_width, &shit->img_height);
ft_window_size(map);
shit->win = mlx_new_window(ok.connection_id, map_width, map_height, "Sh!t_Project");
while(map[y])
{
x = 0;
while(map[y][x])
{
if(map[y][x] == '1')
{
mlx_put_image_to_window(ok.connection_id, shit->win, shit->img_wall, x*50, y*50);
}
else if(map[y][x] == '0')
{
mlx_put_image_to_window(ok.connection_id, shit->win, shit->img_space, x*50, y*50);
}
else if(map[y][x] == 'P')
{
mlx_put_image_to_window(ok.connection_id, shit->win, shit->img_player, x*50, y*50);
}
else if(map[y][x] == 'C')
{
mlx_put_image_to_window(ok.connection_id, shit->win, shit->img_colect, x*50, y*50);
}
else if(map[y][x] == 'E')
{
mlx_put_image_to_window(ok.connection_id, shit->win, shit->img_exit, x*50, y*50);
}
x++;
}
y++;
}
mlx_loop(ok.connection_id);
return (0);
}