Add floor mirror

This commit is contained in:
Miloslav Číž 2018-09-17 13:03:35 +02:00
parent 189140db7a
commit e91fb33a89

View file

@ -31,6 +31,9 @@
//#define NO_SHADING //#define NO_SHADING
/* ^ Turns off shading (fog) which increases FPS. */ /* ^ Turns off shading (fog) which increases FPS. */
//#define NO_MIRROR
/* ^ Turns off the floor mirror effect, which should increase FPS. */
//#define USE_DIST_APPROX 1 //#define USE_DIST_APPROX 1
/* ^ Turns on distance approximation, which won't compute exact distances but /* ^ Turns on distance approximation, which won't compute exact distances but
only approximations - this should increase performance a little, but only approximations - this should increase performance a little, but
@ -925,6 +928,8 @@ bool shotFired = false;
uint8_t previousColumn = 255; ///< Helper for pixelIntensity. uint8_t previousColumn = 255; ///< Helper for pixelIntensity.
int8_t pixelIntensity = 0; ///< Precomputed column intensity addition. int8_t pixelIntensity = 0; ///< Precomputed column intensity addition.
int16_t mirror = 0;
/** /**
Function for drawing a single pixel (like fragment shader). Function for drawing a single pixel (like fragment shader).
*/ */
@ -935,9 +940,25 @@ inline void pixelFunc(PixelInfo *pixel)
uint8_t c = 0; uint8_t c = 0;
#ifndef NO_MIRROR
if (pixel->position.y == 0)
mirror = 0;
#endif
if (!pixel->isWall) if (!pixel->isWall)
{ {
c = pixel->isFloor ? cFloor: cCeiling; c = pixel->isFloor ? cFloor: cCeiling;
#ifndef NO_MIRROR
int16_t intensity = pixel->isFloor ?
-1 * (pixel->depth - mirror * 64) / UNITS_PER_SQUARE : 0;
#else
int16_t intensity = -1 * pixel->depth / (UNITS_PER_SQUARE * 2);
#endif
c = addIntensity(c,intensity);
mirror++;
} }
else else
{ {
@ -1006,8 +1027,8 @@ int main()
for (uint8_t i = 0; i < TEXTURES; ++i) for (uint8_t i = 0; i < TEXTURES; ++i)
textureAverageColors[i] = computeAverageColor(textures[i]); textureAverageColors[i] = computeAverageColor(textures[i]);
cFloor = rgbToIndex(0,1,1); cFloor = rgbToIndex(3,3,2);
cCeiling = rgbToIndex(1,0,1); cCeiling = rgbToIndex(3,2,0);
player.setPositionSquare(6,5); player.setPositionSquare(6,5);
player.mCamera.height = CAMERA_COLL_HEIGHT_BELOW; player.mCamera.height = CAMERA_COLL_HEIGHT_BELOW;