1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/raycastlib.git synced 2024-11-21 20:29:59 +01:00

Add comments

This commit is contained in:
Miloslav Číž 2018-09-09 17:20:44 +02:00
parent cdc71ac981
commit 303f5cee60

View file

@ -154,9 +154,19 @@ typedef struct
It should return a characteristic of given square as an integer (e.g. square It should return a characteristic of given square as an integer (e.g. square
height, texture index, ...) - between squares that return different numbers height, texture index, ...) - between squares that return different numbers
there is considered to be a collision. there is considered to be a collision.
This function should be as fast as possible as it will typically be called
very often.
*/ */
typedef Unit (*ArrayFunction)(int16_t x, int16_t y); typedef Unit (*ArrayFunction)(int16_t x, int16_t y);
/**
Function that renders a single pixel at the display. It is handed an info
about the pixel it should draw.
This function should be as fast as possible as it will typically be called
very often.
*/
typedef void (*PixelFunction)(PixelInfo info); typedef void (*PixelFunction)(PixelInfo info);
typedef void typedef void
@ -180,7 +190,15 @@ void castRayMultiHit(Ray ray, ArrayFunction arrayFunc, ArrayFunction typeFunc,
HitResult *hitResults, uint16_t *hitResultsLen, RayConstraints constraints); HitResult *hitResults, uint16_t *hitResultsLen, RayConstraints constraints);
Vector2D angleToDirection(Unit angle); Vector2D angleToDirection(Unit angle);
/**
Cos function.
@param input to cos in Units (UNITS_PER_SQUARE = 2 * pi = 360 degrees)
@return normalized output in Units (from -UNITS_PER_SQUARE to UNITS_PER_SQUARE)
*/
Unit cosInt(Unit input); Unit cosInt(Unit input);
Unit sinInt(Unit input); Unit sinInt(Unit input);
/// Normalizes given vector to have UNITS_PER_SQUARE length. /// Normalizes given vector to have UNITS_PER_SQUARE length.
@ -226,6 +244,22 @@ void render(Camera cam, ArrayFunction floorHeightFunc,
ArrayFunction ceilingHeightFunc, ArrayFunction typeFunction, ArrayFunction ceilingHeightFunc, ArrayFunction typeFunction,
PixelFunction pixelFunc, RayConstraints constraints); PixelFunction pixelFunc, RayConstraints constraints);
/**
Function that moves given camera and makes it collide with walls and
potentially also floor and ceilings. It's meant to help implement player
movement.
@param camera camera to move
@param planeOffset offset to move the camera in
@param heightOffset height offset to move the camera in
@param floorHeightFunc function used to retrieve the floor height
@param ceilingHeightFunc function for retrieving ceiling height, can be 0
(camera won't collide with ceiling)
@param computeHeight whether to compute height - if false (0), floor and
ceiling functions won't be used and the camera will
only collide horizontally with walls (good for simpler
game, also faster)
*/
void moveCameraWithCollision(Camera *camera, Vector2D planeOffset, void moveCameraWithCollision(Camera *camera, Vector2D planeOffset,
Unit heightOffset, ArrayFunction floorHeightFunc, Unit heightOffset, ArrayFunction floorHeightFunc,
ArrayFunction ceilingHeightFunc, int8_t computeHeight); ArrayFunction ceilingHeightFunc, int8_t computeHeight);