possibility to choose angle of view
This commit is contained in:
@@ -12,6 +12,7 @@ static void init_map(t_map *map)
|
||||
{
|
||||
map->size_x = 24;
|
||||
map->size_y = 24;
|
||||
map->cell = CELL;
|
||||
// map
|
||||
int tmp[24][24] = {
|
||||
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
|
||||
@@ -64,21 +65,26 @@ static void init_map(t_map *map)
|
||||
|
||||
static void init_raycast(t_rcast *rcast)
|
||||
{
|
||||
// draw screen dist
|
||||
double dist;
|
||||
|
||||
dist = (SCREEN_FOCAL / 2) * M_PI / 180;
|
||||
dist = cos(dist) * ((SCREEN_DEF / 2) / sin(dist));
|
||||
rcast->screen_def = SCREEN_DEF;
|
||||
// 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 = -SCREEN_DIST;
|
||||
// draw screen size
|
||||
rcast->screen_size.start.x = -SCREEN_SIZE / 2;
|
||||
rcast->screen_size.start.y = -SCREEN_DIST;
|
||||
rcast->screen_size.end.x = SCREEN_SIZE / 2;
|
||||
rcast->screen_size.end.y = -SCREEN_DIST;
|
||||
// draw ray
|
||||
rcast->screen_dist.end.y = -dist;
|
||||
// screen size
|
||||
rcast->screen_size.start.x = -SCREEN_DEF / 2;
|
||||
rcast->screen_size.start.y = -dist;
|
||||
rcast->screen_size.end.x = SCREEN_DEF / 2;
|
||||
rcast->screen_size.end.y = -dist;
|
||||
// first ray
|
||||
rcast->ray.start.x = 0;
|
||||
rcast->ray.start.y = 0;
|
||||
rcast->ray.end.x = -SCREEN_SIZE / 2;
|
||||
rcast->ray.end.y = -SCREEN_DIST;
|
||||
rcast->ray.end.x = -SCREEN_DEF / 2;
|
||||
rcast->ray.end.y = -dist;
|
||||
}
|
||||
|
||||
static void init_plr(t_plr *plr)
|
||||
@@ -118,6 +124,7 @@ t_game *init_game(void)
|
||||
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