wip solving buble effect by wall height calculation
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
/* screen width */
|
||||
# define SCREEN_WIDTH 500
|
||||
/* screen height */
|
||||
# define SCREEN_HEIGHT 200
|
||||
# define SCREEN_HEIGHT 300
|
||||
/* screen focal (in degree) */
|
||||
# define SCREEN_FOCAL 90
|
||||
/* size of a cell on the map */
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef CUBE3D_PROTO_H
|
||||
# define CUBE3D_PROTO_H
|
||||
|
||||
void plr_turn(t_plr *plr, int deg);
|
||||
|
||||
// -------------------------------
|
||||
// SRC
|
||||
// -------------------------------
|
||||
|
||||
@@ -42,11 +42,6 @@ int main(int ac, char **av)
|
||||
mb_init(destroy_mlx, game);
|
||||
|
||||
// draw game a first time before it start
|
||||
|
||||
// tmp
|
||||
plr_turn(&game->plr, -63);
|
||||
// tmp end
|
||||
|
||||
draw(game);
|
||||
|
||||
// receive a keypress event
|
||||
|
||||
@@ -57,6 +57,7 @@ static void wall_height(t_rcast *rcast)
|
||||
{
|
||||
int height;
|
||||
|
||||
/*
|
||||
height = rcast->screen_height * (rcast->hor - rcast->ray_len) / rcast->hor;
|
||||
|
||||
if (height < 0)
|
||||
@@ -66,6 +67,16 @@ static void wall_height(t_rcast *rcast)
|
||||
|
||||
rcast->wall.start.y = rcast->screen_height / 2 + height / 2;
|
||||
rcast->wall.end.y = rcast->screen_height / 2 - height / 2;
|
||||
*/
|
||||
if (rcast->ray_len)
|
||||
height = rcast->screen_height / rcast->ray_len;
|
||||
|
||||
rcast->wall.start.y = -height / 2 + rcast->screen_height / 2;
|
||||
if (rcast->wall.start.y < 0)
|
||||
rcast->wall.start.y = 0;
|
||||
rcast->wall.end.y = height / 2 + rcast->screen_height / 2;
|
||||
if (rcast->wall.end.y >= rcast->screen_height)
|
||||
rcast->wall.end.y = rcast->screen_height;
|
||||
}
|
||||
|
||||
void draw_column(t_game *game, t_rcast *rcast)
|
||||
|
||||
@@ -73,18 +73,3 @@ void plr_turn_right(t_plr *plr)
|
||||
plr->cosj = cos(radj);
|
||||
plr->sinj = sin(radj);
|
||||
}
|
||||
|
||||
void plr_turn(t_plr *plr, int deg)
|
||||
{
|
||||
double radi;
|
||||
double radj;
|
||||
|
||||
plr->rot = deg;
|
||||
// calculate trigo for rotations
|
||||
radi = plr->rot * M_PI / 180;
|
||||
radj = radi + (M_PI / 2);
|
||||
plr->cosi = cos(radi);
|
||||
plr->sini = sin(radi);
|
||||
plr->cosj = cos(radj);
|
||||
plr->sinj = sin(radj);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user