Bring Amit's latest fix in and protect against the sprites rendering the texY value wrong sometimes.
This commit is contained in:
parent
379ec5846f
commit
6592e22075
2 changed files with 33 additions and 45 deletions
|
@ -7,9 +7,10 @@
|
|||
|
||||
using namespace fmt;
|
||||
|
||||
static constexpr auto room_brightness = 0.3f; // increse this to increase the room brightness. Higher value means brighter room.
|
||||
|
||||
#ifdef AMT_LIGHT
|
||||
static constexpr auto room_brightness = 0.3f; // increse this to increase the room brightness. Higher value means brighter room.
|
||||
|
||||
inline static constexpr amt::RGBA dumb_lighting(amt::RGBA pixel, double distance, double distance_from_center) {
|
||||
auto const dim_pixel = pixel * room_brightness;
|
||||
if (distance_from_center >= 0) {
|
||||
|
@ -145,6 +146,7 @@ void Raycaster::sprite_casting() {
|
|||
int texY = ((d * textureHeight) / spriteHeight) / 256;
|
||||
//get current color from the texture
|
||||
// BUG: this crashes sometimes when the math goes out of bounds
|
||||
if(texY < 0 || texY >= (int)sprite_texture.rows()) continue;
|
||||
auto color = sprite_texture[texY][texX];
|
||||
// poor person's transparency, get current color from the texture
|
||||
pixels[y][stripe] = (color.to_hex() & 0xffffff00) ? color: pixels[y][stripe];
|
||||
|
@ -323,11 +325,20 @@ void Raycaster::draw_ceiling_floor() {
|
|||
// this uses the previous ty/tx fractional parts of
|
||||
// floorX cellX to find the texture x/y. How?
|
||||
|
||||
#ifdef AMT_LIGHT
|
||||
// FLOOR
|
||||
pixels[y][x] = textures.floor[ty][tx] * room_brightness;
|
||||
|
||||
// CEILING
|
||||
pixels[$height - y - 1][x] = textures.ceiling[ty][tx] * room_brightness;
|
||||
#else
|
||||
// FLOOR
|
||||
pixels[y][x] = textures.floor[ty][tx];
|
||||
|
||||
// CEILING
|
||||
pixels[$height - y - 1][x] = textures.ceiling[ty][tx];
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue