From d573101459191ca1018c3112e615a22eb683cd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 18 Sep 2018 10:24:57 +0200 Subject: [PATCH] Add floor textures --- demo2.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/demo2.cpp b/demo2.cpp index a267851..c51304a 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -28,6 +28,10 @@ //#define NO_TEXTURES /* ^ 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 /* ^ Turns off shading (fog) which increases FPS. */ @@ -53,7 +57,7 @@ #define RCL_COMPUTE_WALL_TEXCOORDS 0 #endif -#define FPS 256 +#define FPS 255 #define HEAD_BOB_HEIGHT 200 #define HEAD_BOB_STEP 20 #define PLAYER_SPEED (5 * RCL_UNITS_PER_SQUARE) @@ -947,7 +951,13 @@ inline void pixelFunc(RCL_PixelInfo *pixel) 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; +#endif #ifndef NO_MIRROR int16_t intensity = pixel->isFloor ? @@ -1079,6 +1089,12 @@ int main() bool strafe = pokitto.aBtn(); +if (pokitto.aBtn()) + player.mCamera.height += 50; + +if (pokitto.bBtn()) + player.mCamera.height -= 50; + if (!strafe) { if (pokitto.upBtn())