texture in place, but they slide :p

This commit is contained in:
hugogogo
2022-05-03 13:11:26 +02:00
parent 5b60406124
commit a9c25ee5df

View File

@@ -32,49 +32,31 @@ static int get_texture(t_img *img, int imgx, int j, int height)
return (*(int*)color); return (*(int*)color);
} }
static void draw_txt_column(t_img *img, t_rcast *rcast, t_wall *wall, t_img *txt_img, int color) static void draw_txt_column(t_img *img, t_rcast *rcast, t_wall *wall, t_img *txt_img)
{ {
(void)img; int color;
(void)wall;
(void)txt_img;
(void)color;
// draw_line(img, &wall->vec, color);
int img_x; int img_x;
int j; int j;
img_x = (wall->posx * txt_img->width) / rcast->cell; img_x = (wall->posx * txt_img->width) / rcast->cell;
//printf("img_x:%i - img_width:%i\n", img_x, txt_img->width);
j = 0; j = 0;
while (j < wall->height) while (j < wall->height)
{ {
color = get_texture(txt_img, img_x, j, wall->height); color = get_texture(txt_img, img_x, j, wall->height);
draw_pixel(img, wall->vec.start.x, wall->vec.start.y + j, color); draw_pixel(img, wall->vec.start.x, wall->vec.end.y + j, color);
j++; j++;
} }
} }
void draw_column(t_game *game, t_rcast *rcast, t_wall *wall, t_txt *txt) void draw_column(t_game *game, t_rcast *rcast, t_wall *wall, t_txt *txt)
{ {
int color_n;
int color_s;
int color_e;
int color_o;
(void)wall;
color_n = 0x00FF00FF;
color_s = 0x0000EEEE;
color_e = 0x00DDDD00;
color_o = 0x00CCCCCC;
draw_floor_ceiling(game, rcast, txt); draw_floor_ceiling(game, rcast, txt);
if (!rcast->is_x && rcast->slope_y > 0) if (!rcast->is_x && rcast->slope_y > 0)
draw_txt_column(&game->img, rcast, wall, &txt->img_n, color_n); draw_txt_column(&game->img, rcast, wall, &txt->img_n);
if (!rcast->is_x && rcast->slope_y < 0) if (!rcast->is_x && rcast->slope_y < 0)
draw_line(&game->img, &rcast->wall.vec, color_s); draw_txt_column(&game->img, rcast, wall, &txt->img_s);
if (rcast->is_x && rcast->slope_x > 0) if (rcast->is_x && rcast->slope_x > 0)
draw_line(&game->img, &rcast->wall.vec, color_e); draw_txt_column(&game->img, rcast, wall, &txt->img_e);
if (rcast->is_x && rcast->slope_x < 0) if (rcast->is_x && rcast->slope_x < 0)
draw_line(&game->img, &rcast->wall.vec, color_o); draw_txt_column(&game->img, rcast, wall, &txt->img_w);
} }