Skip to content

Commit

Permalink
Tweak raycaster wall and floor colors
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb committed Oct 10, 2023
1 parent abe293c commit a278895
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ncc/examples/3dcube.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ int main()
persp
);

// Translation matrix for the cube
mat44_translate(cube_pos, trans);


return 0;
}
20 changes: 13 additions & 7 deletions ncc/examples/raycaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,23 @@ void paint_column(int col_idx, float dx, float dy, float frame_dst, float ray_ds

//printf("wall_top=%f, wall_bot=%f\n", wall_top, wall_bot);

// TODO: optimize this loop
for (int y = 0; y < FRAME_HEIGHT; ++y)
// Paint the ceiling
for (int y = 0; y < wall_min_y; ++y)
{
if (y < wall_min_y || y > wall_max_y)
{
frame_buffer[y][col_idx] = COLOR_BLUE;
continue;
}
frame_buffer[y][col_idx] = rgb32(50, 50, 50);
}

// Paint the wall strip
for (int y = wall_min_y; y < wall_max_y; ++y)
{
frame_buffer[y][col_idx] = wall_color;
}

// Paint the floor
for (int y = wall_max_y; y < FRAME_HEIGHT; ++y)
{
frame_buffer[y][col_idx] = rgb32(100, 100, 100);
}
}

void anim_callback()
Expand Down

0 comments on commit a278895

Please sign in to comment.