44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
#include "cube3d.h"
|
|
|
|
void draw_floor_ceiling(t_game *game, t_rcast *rcast, t_txt *txt)
|
|
{
|
|
t_vec plan;
|
|
|
|
plan.start.x = rcast->ray_nb;
|
|
plan.end.x = rcast->ray_nb;
|
|
if (rcast->wall.start.y > 0)
|
|
{
|
|
plan.start.y = rcast->screen_height;
|
|
plan.end.y = rcast->wall.start.y;
|
|
draw_line(&game->img, &plan, txt->rgb_floor);
|
|
}
|
|
if (rcast->wall.start.y < rcast->screen_height)
|
|
{
|
|
plan.start.y = rcast->wall.end.y;
|
|
plan.end.y = 0;
|
|
draw_line(&game->img, &plan, txt->rgb_ceiling);
|
|
}
|
|
}
|
|
|
|
void draw_column(t_game *game, t_rcast *rcast)
|
|
{
|
|
int color_n;
|
|
int color_s;
|
|
int color_e;
|
|
int color_o;
|
|
|
|
color_n = 0x00FF00FF;
|
|
color_s = 0x0000EEEE;
|
|
color_e = 0x00DDDD00;
|
|
color_o = 0x00CCCCCC;
|
|
draw_floor_ceiling(game, rcast, &game->txt);
|
|
if (!rcast->is_x && rcast->slope_y > 0)
|
|
draw_line(&game->img, &rcast->wall, color_n);
|
|
if (!rcast->is_x && rcast->slope_y < 0)
|
|
draw_line(&game->img, &rcast->wall, color_s);
|
|
if (rcast->is_x && rcast->slope_x > 0)
|
|
draw_line(&game->img, &rcast->wall, color_e);
|
|
if (rcast->is_x && rcast->slope_x < 0)
|
|
draw_line(&game->img, &rcast->wall, color_o);
|
|
}
|