The raycaster can now pair a floor with a ceiling tile and to demonstrate this I have a blue light that shines on to a stone floor. I also played with just pixelating a regular image rather than painting it and honestly it looks better in a lot of ways.
This commit is contained in:
parent
e015652f4c
commit
931d9493d2
11 changed files with 50 additions and 39 deletions
|
@ -66,8 +66,6 @@ Raycaster::Raycaster(int width, int height) :
|
|||
$view_sprite.setPosition({0, 0});
|
||||
$pixels = make_unique<RGBA[]>($width * $height);
|
||||
$view_texture.setSmooth(false);
|
||||
$floor_texture = textures::get_floor();
|
||||
$ceiling_texture = textures::get_ceiling();
|
||||
}
|
||||
|
||||
void Raycaster::set_position(int x, int y) {
|
||||
|
@ -329,6 +327,8 @@ void Raycaster::draw_ceiling_floor() {
|
|||
constexpr static const int texture_height = TEXTURE_HEIGHT;
|
||||
auto &lights = $level.lights->lighting();
|
||||
size_t surface_i = 0;
|
||||
const uint32_t *floor_texture = textures::get_surface(surface_i);
|
||||
const uint32_t *ceiling_texture = textures::get_ceiling(surface_i);
|
||||
|
||||
for(int y = $height / 2 + 1; y < $height; ++y) {
|
||||
// rayDir for leftmost ray (x=0) and rightmost (x = w)
|
||||
|
@ -388,18 +388,18 @@ void Raycaster::draw_ceiling_floor() {
|
|||
|
||||
if(new_surface_i != surface_i) {
|
||||
surface_i = new_surface_i;
|
||||
$floor_texture = textures::get_surface(surface_i);
|
||||
$ceiling_texture = textures::get_surface(surface_i);
|
||||
floor_texture = textures::get_surface(surface_i);
|
||||
ceiling_texture = textures::get_ceiling(surface_i);
|
||||
}
|
||||
|
||||
// NOTE: use map_x/y to get the floor, ceiling texture.
|
||||
|
||||
// FLOOR
|
||||
color = $floor_texture[texture_width * ty + tx];
|
||||
color = floor_texture[texture_width * ty + tx];
|
||||
$pixels[pixcoord(x, y)] = lighting_calc(color, row_distance, light_level);
|
||||
|
||||
// CEILING
|
||||
color = $ceiling_texture[texture_width * ty + tx];
|
||||
color = ceiling_texture[texture_width * ty + tx];
|
||||
$pixels[pixcoord(x, $height - y - 1)] = lighting_calc(color, row_distance, light_level);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue