From fb8ae0f162a3467bc4757b1ebd212d20c013f0c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Fri, 21 Sep 2018 08:47:42 +0200 Subject: [PATCH] Update --- demo1.cpp | 2 +- demo2.cpp | 29 ++++++++++++++++++++++++----- demo3.cpp | 3 ++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/demo1.cpp b/demo1.cpp index fa8efeb..73fcca6 100644 --- a/demo1.cpp +++ b/demo1.cpp @@ -1031,7 +1031,7 @@ inline void pixelFunc(RCL_PixelInfo *pixel) void draw() { - RCL_render(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,defaultConstraints); + RCL_renderComplex(player.mCamera,floorHeightAt,ceilingHeightAt,textureAt,defaultConstraints); RCL_Unit previousDepth; diff --git a/demo2.cpp b/demo2.cpp index fcb35c1..fa5f5e4 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -20,7 +20,7 @@ that will be cast. The result looks beautiful but dramatically decreases FPS. */ -//#define RENDER_PRECISE +//#define RENDER_COMPLEX /* ^ 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 some features (rooling doors, floor textures, @@ -33,7 +33,7 @@ /* ^ Turns on computation of texture coordinates for the floor in raycastlib 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 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_H 32 +#ifndef RCL_COMPUTE_FLOOR_TEXCOORDS +#define RCL_COMPUTE_CEILING_DEPTH 0 +#endif + #include "general.hpp" #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]; -#ifdef RENDER_PRECISE +#ifdef RENDER_COMPLEX /* algorithm used with this version doesn't support rolling doors, so give door square zero height */ return square == 0 || square == 6 ? 0 : RCL_UNITS_PER_SQUARE * 2; @@ -1008,8 +1012,8 @@ void draw() player.mCamera.height += player.mHeadBob; #endif -#ifdef RENDER_PRECISE - RCL_render(player.mCamera,floorHeightAt,0,textureAt,defaultConstraints); +#ifdef RENDER_COMPLEX + RCL_renderComplex(player.mCamera,floorHeightAt,0,textureAt,defaultConstraints); #else RCL_renderSimple(player.mCamera,floorHeightAt,textureAt,rollAt,defaultConstraints); #endif @@ -1028,6 +1032,21 @@ void draw() } 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() diff --git a/demo3.cpp b/demo3.cpp index c30ef56..a694500 100644 --- a/demo3.cpp +++ b/demo3.cpp @@ -20,6 +20,7 @@ #define HEAD_BOB_STEP 20 #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_H 32 @@ -502,7 +503,7 @@ bool flyBy = true; void draw() { 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; if (flyBy && (pokitto.frameCount >> 3) % 3 != 0)