add place for game window
This commit is contained in:
@@ -68,22 +68,22 @@ static void init_raycast(t_rcast *rcast)
|
||||
double dist;
|
||||
|
||||
dist = (SCREEN_FOCAL / 2) * M_PI / 180;
|
||||
dist = cos(dist) * ((SCREEN_DEF / 2) / sin(dist));
|
||||
rcast->screen_def = SCREEN_DEF;
|
||||
dist = cos(dist) * ((SCREEN_WIDTH / 2) / sin(dist));
|
||||
rcast->screen_def = SCREEN_WIDTH;
|
||||
// screen dist
|
||||
rcast->screen_dist.start.x = 0;
|
||||
rcast->screen_dist.start.y = 0;
|
||||
rcast->screen_dist.end.x = 0;
|
||||
rcast->screen_dist.end.y = -dist;
|
||||
// screen size
|
||||
rcast->screen_size.start.x = -SCREEN_DEF / 2;
|
||||
rcast->screen_size.start.x = -SCREEN_WIDTH / 2;
|
||||
rcast->screen_size.start.y = -dist;
|
||||
rcast->screen_size.end.x = SCREEN_DEF / 2;
|
||||
rcast->screen_size.end.x = SCREEN_WIDTH / 2;
|
||||
rcast->screen_size.end.y = -dist;
|
||||
// first ray
|
||||
rcast->ray.start.x = 0;
|
||||
rcast->ray.start.y = 0;
|
||||
rcast->ray.end.x = -SCREEN_DEF / 2;
|
||||
rcast->ray.end.x = -SCREEN_WIDTH / 2;
|
||||
rcast->ray.end.y = -dist;
|
||||
}
|
||||
|
||||
@@ -111,21 +111,30 @@ t_game *init_game(void)
|
||||
init_map(&(game->map));
|
||||
// plr
|
||||
init_plr(&(game->plr));
|
||||
// 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");
|
||||
|
||||
// tmp draw map
|
||||
// size window map
|
||||
game->map_win.size_x = game->map.size_x * CELL;
|
||||
game->map_win.size_y = game->map.size_y * CELL + SCREEN_HEIGHT;
|
||||
// create the window
|
||||
game->map_win.ptr = mlx_new_window(game->mlx_ptr, game->map_win.size_x,
|
||||
game->map_win.size_y, "map");
|
||||
// create image and get its data address
|
||||
init_img(&(game->map_img), game);
|
||||
// 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);
|
||||
// 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;
|
||||
// create image and get its data address
|
||||
init_img(&(game->map_img), game);
|
||||
return (game);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user