Add floor textures

This commit is contained in:
Miloslav Číž 2018-09-18 10:24:57 +02:00
parent 6b9de75174
commit d573101459

View file

@ -28,6 +28,10 @@
//#define NO_TEXTURES //#define NO_TEXTURES
/* ^ Turns off textures and only uses colors, which increases FPS. */ /* ^ Turns off textures and only uses colors, which increases FPS. */
//#define RCL_COMPUTE_FLOOR_TEXCOORDS 1
/* ^ Turns on computation of texture coordinates for the floor in raycastlib
and makes this demo render the textures. */
//#define NO_SHADING //#define NO_SHADING
/* ^ Turns off shading (fog) which increases FPS. */ /* ^ Turns off shading (fog) which increases FPS. */
@ -53,7 +57,7 @@
#define RCL_COMPUTE_WALL_TEXCOORDS 0 #define RCL_COMPUTE_WALL_TEXCOORDS 0
#endif #endif
#define FPS 256 #define FPS 255
#define HEAD_BOB_HEIGHT 200 #define HEAD_BOB_HEIGHT 200
#define HEAD_BOB_STEP 20 #define HEAD_BOB_STEP 20
#define PLAYER_SPEED (5 * RCL_UNITS_PER_SQUARE) #define PLAYER_SPEED (5 * RCL_UNITS_PER_SQUARE)
@ -947,7 +951,13 @@ inline void pixelFunc(RCL_PixelInfo *pixel)
if (!pixel->isWall) if (!pixel->isWall)
{ {
#if RCL_COMPUTE_FLOOR_TEXCOORDS == 1
c = pixel->depth > RCL_UNITS_PER_SQUARE * 5 ?
textureAverageColors[1] :
sampleImage(textures[1],pixel->texCoords.x,pixel->texCoords.y);
#else
c = pixel->isFloor ? cFloor: cCeiling; c = pixel->isFloor ? cFloor: cCeiling;
#endif
#ifndef NO_MIRROR #ifndef NO_MIRROR
int16_t intensity = pixel->isFloor ? int16_t intensity = pixel->isFloor ?
@ -1079,6 +1089,12 @@ int main()
bool strafe = pokitto.aBtn(); bool strafe = pokitto.aBtn();
if (pokitto.aBtn())
player.mCamera.height += 50;
if (pokitto.bBtn())
player.mCamera.height -= 50;
if (!strafe) if (!strafe)
{ {
if (pokitto.upBtn()) if (pokitto.upBtn())