wall don't distord when bigger than screen
This commit is contained in:
@@ -20,6 +20,28 @@ static void draw_floor_ceiling(t_game *game, t_rcast *rcast, t_txt *txt)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void draw_line(t_img *img, t_vec *vec, int color)
|
||||
{
|
||||
t_coord dist;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
dist.x = (*vec).end.x - (*vec).start.x;
|
||||
dist.y = (*vec).end.y - (*vec).start.y;
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (ft_abs(i) <= ft_abs(dist.x) && ft_abs(j) <= ft_abs(dist.y))
|
||||
{
|
||||
draw_pixel(img, (*vec).start.x + i, (*vec).start.y + j, color);
|
||||
if (!ft_abs(dist.x) || ft_abs(j) < ft_abs(i * dist.y / dist.x))
|
||||
j += ft_sign(dist.y);
|
||||
else
|
||||
i += ft_sign(dist.x);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static int get_texture(t_img *img, int imgx, int j, int height)
|
||||
{
|
||||
char *color;
|
||||
@@ -34,17 +56,28 @@ static int get_texture(t_img *img, int imgx, int j, int height)
|
||||
|
||||
static void draw_txt_column(t_img *img, t_rcast *rcast, t_wall *wall, t_img *txt_img)
|
||||
{
|
||||
|
||||
int color;
|
||||
int img_x;
|
||||
int i;
|
||||
int j;
|
||||
int limit;
|
||||
|
||||
img_x = (wall->posx * txt_img->width) / rcast->cell;
|
||||
limit = (wall->height - rcast->screen_height) / 2;
|
||||
if (limit < 0)
|
||||
limit = 0;
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (j < wall->height)
|
||||
while (i < wall->height - limit)
|
||||
{
|
||||
color = get_texture(txt_img, img_x, j, wall->height);
|
||||
draw_pixel(img, wall->vec.start.x, wall->vec.end.y + j, color);
|
||||
j++;
|
||||
if (i > limit)
|
||||
{
|
||||
color = get_texture(txt_img, img_x, i, wall->height);
|
||||
draw_pixel(img, wall->vec.start.x, wall->vec.end.y + j, color);
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +86,10 @@ void draw_column(t_game *game, t_rcast *rcast, t_wall *wall, t_txt *txt)
|
||||
draw_floor_ceiling(game, rcast, txt);
|
||||
if (!rcast->is_x && rcast->slope_y > 0)
|
||||
draw_txt_column(&game->img, rcast, wall, &txt->img_n);
|
||||
if (!rcast->is_x && rcast->slope_y < 0)
|
||||
else if (!rcast->is_x && rcast->slope_y < 0)
|
||||
draw_txt_column(&game->img, rcast, wall, &txt->img_s);
|
||||
if (rcast->is_x && rcast->slope_x > 0)
|
||||
else if (rcast->is_x && rcast->slope_x > 0)
|
||||
draw_txt_column(&game->img, rcast, wall, &txt->img_e);
|
||||
if (rcast->is_x && rcast->slope_x < 0)
|
||||
else if (rcast->is_x && rcast->slope_x < 0)
|
||||
draw_txt_column(&game->img, rcast, wall, &txt->img_w);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user