From 67992ff2eb60437722b14c2dd995a00c18551148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 18 Sep 2018 11:25:34 +0200 Subject: [PATCH] Update --- demo2.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/demo2.cpp b/demo2.cpp index c51304a..3c593eb 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -23,15 +23,22 @@ //#define RENDER_PRECISE /* ^ Turns on rendering using a more precise but slower algorithm. This can be seen at less shaky head bobbing when moving. However the latter - algorithm doesn't support rolling doors (these will be turned off). */ + algorithm doesn't support some features (rooling doors, floor textures, + ...). */ //#define NO_TEXTURES /* ^ Turns off textures and only uses colors, which increases FPS. */ -//#define RCL_COMPUTE_FLOOR_TEXCOORDS 1 +#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 FLOOR_TEXTURE_SCALE 2 + /* ^ Scales the floor texture if RCL_COMPUTE_FLOOR_TEXCOORDS is on. */ + +//#define HEAD_BOB + /* ^ Turns on head bobbing. */ + //#define NO_SHADING /* ^ Turns off shading (fog) which increases FPS. */ @@ -952,9 +959,12 @@ 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); + if (pixel->isFloor) + c = pixel->depth > RCL_UNITS_PER_SQUARE * 5 ? + textureAverageColors[1] : + sampleImage(textures[1],pixel->texCoords.x / FLOOR_TEXTURE_SCALE,pixel->texCoords.y / FLOOR_TEXTURE_SCALE); + else + c = 0; // looks better :) #else c = pixel->isFloor ? cFloor: cCeiling; #endif @@ -1008,7 +1018,9 @@ void draw() c.maxHits = 1; c.maxSteps = 20; +#ifdef HEAD_BOB player.mCamera.height += player.mHeadBob; +#endif #ifdef RENDER_PRECISE RCL_render(player.mCamera,floorHeightAt,0,textureAt,c); @@ -1016,7 +1028,9 @@ void draw() RCL_renderSimple(player.mCamera,floorHeightAt,textureAt,rollAt,c); #endif +#ifdef HEAD_BOB player.mCamera.height -= player.mHeadBob; +#endif if (shotFired) { @@ -1043,7 +1057,7 @@ int main() player.setPositionSquare(6,5); player.mCamera.height = RCL_CAMERA_COLL_HEIGHT_BELOW; - player.mCamera.resolution.y = INFO_BAR_START + 1; + player.mCamera.resolution.y = INFO_BAR_START + 2; uint32_t previousTime = 0; uint32_t dt; @@ -1089,12 +1103,6 @@ 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())