Connected parsing to rest of the game

This commit is contained in:
Philippe BLAGOJEVIC
2022-04-23 20:12:13 +02:00
parent fac1f78230
commit f53e66556b
19 changed files with 1010 additions and 23 deletions

View File

@@ -10,7 +10,7 @@ static void init_img(t_img *img, t_game *game)
static void init_map(t_map *map)
{
map->size_x = 24;
/* map->size_x = 24;
map->size_y = 24;
// map
int tmp[24][24] = {
@@ -59,7 +59,21 @@ static void init_map(t_map *map)
j++;
}
i++;
}
} */
map->content = NULL;
map->tmp_str = NULL;
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)
@@ -81,11 +95,11 @@ static void init_raycast(t_rcast *rcast)
rcast->ray.end.y = -SCREEN_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
@@ -96,14 +110,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));
// size window map
game->map_win.size_x = game->map.size_x * CELL;
@@ -119,6 +135,27 @@ t_game *init_game(void)
// raycasting
init_raycast(&(game->rcast));
// create image and get its data address
init_img(&(game->map_img), game);
init_img(&(game->map_img), game); */
return (game);
}
void init_game(t_game *game)
{
// plr
init_plr(&(game->plr), &(game->map));
// size window map
game->map_win.size_x = game->map.size_x * CELL;
game->map_win.size_y = game->map.size_y * CELL;
// init connexion to server
game->mlx_ptr = mlx_init();
mb_add(game->mlx_ptr);
// create the window
game->map_win.ptr = mlx_new_window(game->mlx_ptr, game->map_win.size_x,
game->map_win.size_y, "test");
// 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));
// create image and get its data address
init_img(&(game->map_img), game);
}