Merged parsing_connected branch to master
This commit is contained in:
@@ -9,7 +9,7 @@ static void init_img(t_img *img, void *mlx_ptr, t_win *win)
|
||||
|
||||
static void init_map(t_map *map)
|
||||
{
|
||||
map->size_x = 24;
|
||||
/* map->size_x = 24;
|
||||
map->size_y = 24;
|
||||
map->cell = CELL;
|
||||
// map
|
||||
@@ -59,7 +59,22 @@ static void init_map(t_map *map)
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} */
|
||||
map->content = NULL;
|
||||
map->tmp_str = NULL;
|
||||
map->cell = CELL;
|
||||
map->size_x = 0;
|
||||
map->size_y = 0;
|
||||
map->plr_x = 0;
|
||||
map->plr_y = 0;
|
||||
}
|
||||
|
||||
static void init_txt(t_txt *txt)
|
||||
{
|
||||
txt->txt_north = NULL;
|
||||
txt->txt_south = NULL;
|
||||
txt->txt_east = NULL;
|
||||
txt->txt_west = NULL;
|
||||
}
|
||||
|
||||
static void init_raycast(t_rcast *rcast)
|
||||
@@ -88,11 +103,11 @@ static void init_raycast(t_rcast *rcast)
|
||||
rcast->ray.end.y = -dist;
|
||||
}
|
||||
|
||||
static void init_plr(t_plr *plr)
|
||||
void init_plr(t_plr *plr, t_map *map)
|
||||
{
|
||||
// player first position
|
||||
plr->exact.x = 2 * CELL;
|
||||
plr->exact.y = 2 * CELL;
|
||||
plr->exact.x = map->plr_x * CELL;
|
||||
plr->exact.y = map->plr_y * CELL;
|
||||
plr->pos.x = plr->exact.x;
|
||||
plr->pos.y = plr->exact.y;
|
||||
// rotation
|
||||
@@ -103,14 +118,16 @@ static void init_plr(t_plr *plr)
|
||||
plr->sinj = 0;
|
||||
}
|
||||
|
||||
t_game *init_game(void)
|
||||
t_game *init_struct(void)
|
||||
{
|
||||
t_game *game;
|
||||
|
||||
game = mb_alloc(sizeof(t_game));
|
||||
// map
|
||||
init_map(&(game->map));
|
||||
// plr
|
||||
// init textures and floor/ceiling colors
|
||||
init_txt(&(game->txt));
|
||||
/* // plr
|
||||
init_plr(&(game->plr));
|
||||
// init connexion to server
|
||||
game->mlx_ptr = mlx_init();
|
||||
@@ -133,5 +150,33 @@ t_game *init_game(void)
|
||||
// raycasting
|
||||
init_raycast(&(game->rcast));
|
||||
game->rcast.cell = game->map.cell;
|
||||
// create image and get its data address
|
||||
init_img(&(game->map_img), game); */
|
||||
return (game);
|
||||
}
|
||||
|
||||
void init_game(t_game *game)
|
||||
{
|
||||
// plr
|
||||
init_plr(&(game->plr), &(game->map));
|
||||
// init connexion to server
|
||||
game->mlx_ptr = mlx_init();
|
||||
mb_add(game->mlx_ptr);
|
||||
|
||||
// tmp draw map
|
||||
game->map_win.size_x = game->map.size_x * CELL;
|
||||
game->map_win.size_y = game->map.size_y * CELL + SCREEN_HEIGHT;
|
||||
game->map_win.ptr = mlx_new_window(game->mlx_ptr, game->map_win.size_x, game->map_win.size_y, "map");
|
||||
init_img(&(game->map_img), game->mlx_ptr, &(game->map_win));
|
||||
// tmp end
|
||||
|
||||
game->win.size_x = SCREEN_WIDTH;
|
||||
game->win.size_y = SCREEN_HEIGHT;
|
||||
game->win.ptr = mlx_new_window(game->mlx_ptr, game->win.size_x, game->win.size_y, "cub3d");
|
||||
init_img(&(game->img), game->mlx_ptr, &(game->win));
|
||||
// k(ey)_hook is the array containing the values of key press events
|
||||
ft_bzero(&game->k_hook, sizeof(game->k_hook));
|
||||
// raycasting
|
||||
init_raycast(&(game->rcast));
|
||||
game->rcast.cell = game->map.cell;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user