This commit is contained in:
Miloslav Číž 2018-09-21 08:47:42 +02:00
parent 6ac29936ca
commit fb8ae0f162
3 changed files with 27 additions and 7 deletions

View file

@ -1031,7 +1031,7 @@ inline void pixelFunc(RCL_PixelInfo *pixel)
void draw() void draw()
{ {
RCL_render(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,defaultConstraints); RCL_renderComplex(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,defaultConstraints);
RCL_Unit previousDepth; RCL_Unit previousDepth;

View file

@ -20,7 +20,7 @@
that will be cast. The result looks beautiful but dramatically decreases that will be cast. The result looks beautiful but dramatically decreases
FPS. */ FPS. */
//#define RENDER_PRECISE //#define RENDER_COMPLEX
/* ^ Turns on rendering using a more precise but slower algorithm. This can /* ^ Turns on rendering using a more precise but slower algorithm. This can
be seen at less shaky head bobbing when moving. However the latter be seen at less shaky head bobbing when moving. However the latter
algorithm doesn't support some features (rooling doors, floor textures, algorithm doesn't support some features (rooling doors, floor textures,
@ -33,7 +33,7 @@
/* ^ Turns on computation of texture coordinates for the floor in raycastlib /* ^ Turns on computation of texture coordinates for the floor in raycastlib
and makes this demo render the textures. */ and makes this demo render the textures. */
//#define TEXTURE_CEILING #define TEXTURE_CEILING
/* ^ Turns on texture on ceiling (RCL_COMPUTE_FLOOR_TEXCOORDS must be turned /* ^ Turns on texture on ceiling (RCL_COMPUTE_FLOOR_TEXCOORDS must be turned
on as well for this to work). */ on as well for this to work). */
@ -76,6 +76,10 @@
#define TEXTURE_W 32 // for the sake of performance we require prespecified sizes #define TEXTURE_W 32 // for the sake of performance we require prespecified sizes
#define TEXTURE_H 32 #define TEXTURE_H 32
#ifndef RCL_COMPUTE_FLOOR_TEXCOORDS
#define RCL_COMPUTE_CEILING_DEPTH 0
#endif
#include "general.hpp" #include "general.hpp"
#define LEVEL_X_RES 32 #define LEVEL_X_RES 32
@ -847,7 +851,7 @@ RCL_Unit floorHeightAt(int16_t x, int16_t y)
RCL_Unit square = level[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x]; RCL_Unit square = level[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x];
#ifdef RENDER_PRECISE #ifdef RENDER_COMPLEX
/* algorithm used with this version doesn't support rolling doors, so give /* algorithm used with this version doesn't support rolling doors, so give
door square zero height */ door square zero height */
return square == 0 || square == 6 ? 0 : RCL_UNITS_PER_SQUARE * 2; return square == 0 || square == 6 ? 0 : RCL_UNITS_PER_SQUARE * 2;
@ -1008,8 +1012,8 @@ void draw()
player.mCamera.height += player.mHeadBob; player.mCamera.height += player.mHeadBob;
#endif #endif
#ifdef RENDER_PRECISE #ifdef RENDER_COMPLEX
RCL_render(player.mCamera,floorHeightAt,0,textureAt,defaultConstraints); RCL_renderComplex(player.mCamera,floorHeightAt,0,textureAt,defaultConstraints);
#else #else
RCL_renderSimple(player.mCamera,floorHeightAt,textureAt,rollAt,defaultConstraints); RCL_renderSimple(player.mCamera,floorHeightAt,textureAt,rollAt,defaultConstraints);
#endif #endif
@ -1028,6 +1032,21 @@ void draw()
} }
drawImage(imageBar,0,INFO_BAR_START - 3); drawImage(imageBar,0,INFO_BAR_START - 3);
// uncomment for debuggin camera
/*
pokitto.display.setColor(255);
pokitto.display.setCursor(1,1);
pokitto.display.print(player.mCamera.position.x);
pokitto.display.print(" ");
pokitto.display.print(player.mCamera.position.y);
pokitto.display.print(" ");
pokitto.display.print(player.mCamera.height);
pokitto.display.print(" ");
pokitto.display.print(player.mCamera.direction);
*/
} }
int main() int main()

View file

@ -20,6 +20,7 @@
#define HEAD_BOB_STEP 20 #define HEAD_BOB_STEP 20
#define RCL_COMPUTE_WALL_TEXCOORDS 0 // we won't be using textures, so turn them off #define RCL_COMPUTE_WALL_TEXCOORDS 0 // we won't be using textures, so turn them off
#define RCL_COMPUTE_CEILING_DEPTH 0 // again, we don't need ceiling depth
#define TEXTURE_W 32 // required to define even though we use no textures #define TEXTURE_W 32 // required to define even though we use no textures
#define TEXTURE_H 32 #define TEXTURE_H 32
@ -502,7 +503,7 @@ bool flyBy = true;
void draw() void draw()
{ {
player.mCamera.height += player.mHeadBob; player.mCamera.height += player.mHeadBob;
RCL_render(player.mCamera,floorHeightAt,0,colorAt,defaultConstraints); RCL_renderComplex(player.mCamera,floorHeightAt,0,colorAt,defaultConstraints);
player.mCamera.height -= player.mHeadBob; player.mCamera.height -= player.mHeadBob;
if (flyBy && (pokitto.frameCount >> 3) % 3 != 0) if (flyBy && (pokitto.frameCount >> 3) % 3 != 0)