Adjust helloRay

This commit is contained in:
Miloslav Číž 2018-09-30 14:12:21 +02:00
parent 1ab06b89d4
commit ffb82ec01e

View file

@ -10,19 +10,22 @@
function that will render pixels. It allows super performance. */ function that will render pixels. It allows super performance. */
#define RCL_COMPUTE_WALL_TEXCOORDS 0 #define RCL_COMPUTE_WALL_TEXCOORDS 0
/* ^ We won't be using textures, so turn them off. */ #define RCL_COMPUTE_FLOOR_TEXCOORDS 0
#define RCL_COMPUTE_FLOOR_DEPTH 0
#define RCL_COMPUTE_FLOOR_DEPTH 0
#define RCL_COMPUTE_CEILING_DEPTH 0
/* ^ Turn off features we won't be using, so that the program runs faster.
/* There are many other options that can be defined here, check the library There are many other options that can be defined here, check the library
for details. Don't forget to disable the features you won't be using - it for details. */
will speed up the rendering. */
#include "raycastlib.h" #include "raycastlib.h"
#include "Pokitto.h" #include "Pokitto.h"
Pokitto::Core pokitto; Pokitto::Core pokitto;
RCL_Camera camera; // Defines a view that will be rendered. RCL_Camera camera; // Defines a view that will be rendered.
RCL_RayConstraints constraints; RCL_RayConstraints constraints; // Says the details of casting individual rays.
/* Function that for given square coordinates returns height of the floor /* Function that for given square coordinates returns height of the floor
(in RCL_Units). */ (in RCL_Units). */
@ -35,7 +38,9 @@ RCL_Unit floorHeightAt(int16_t x, int16_t y)
make the walls twice as high. */ make the walls twice as high. */
/* You can either generate the level procedurally as above, or read it from /* You can either generate the level procedurally as above, or read it from
an array and return it here. */ an array and return it here. You can also animate the level here, there
are no limits. Just keep in mind this function should be fast because
it will get called a lot. */
} }
/* Function that will be called by the library in order to draw individual /* Function that will be called by the library in order to draw individual
@ -46,7 +51,7 @@ void pixelFunc(RCL_PixelInfo *pixel)
uint8_t color; uint8_t color;
/* The pixel variable holds all kind of info about the pixel to be rendered. /* The pixel variable holds all kind of info about the pixel to be rendered.
Check the PixelInfo struct for details. */ Check the RCL_PixelInfo struct for details. */
if (pixel->isWall) if (pixel->isWall)
color = pixel->hit.direction + 2; // give walls different colors color = pixel->hit.direction + 2; // give walls different colors
@ -76,9 +81,9 @@ int main()
RCL_initCamera(&camera); /* To initialize all parameters so that none RCL_initCamera(&camera); /* To initialize all parameters so that none
remains undefined. */ remains undefined. */
// Set the camera position to square [4;6]. // Set the camera position to the middle of square [2;3].
camera.position.x = 4 * RCL_UNITS_PER_SQUARE; camera.position.x = 2 * RCL_UNITS_PER_SQUARE + RCL_UNITS_PER_SQUARE / 2;
camera.position.y = 6 * RCL_UNITS_PER_SQUARE; camera.position.y = 3 * RCL_UNITS_PER_SQUARE + RCL_UNITS_PER_SQUARE / 2;
camera.height = RCL_UNITS_PER_SQUARE; camera.height = RCL_UNITS_PER_SQUARE;