Use Chebyshew instead Euclid

This commit is contained in:
Miloslav Číž 2018-09-09 19:56:12 +02:00
parent 73c340a9b6
commit 5fe7c1a926

View file

@ -7,6 +7,7 @@
license: CC0 1.0 license: CC0 1.0
*/ */
// redefine player's height
#define CAMERA_COLL_HEIGHT_BELOW ((3 * UNITS_PER_SQUARE) / 2) #define CAMERA_COLL_HEIGHT_BELOW ((3 * UNITS_PER_SQUARE) / 2)
#include "general.hpp" #include "general.hpp"
@ -665,7 +666,11 @@ void draw()
for (uint8_t i = 0; i < SPRITES; ++i) for (uint8_t i = 0; i < SPRITES; ++i)
{ {
if (dist(sprites[i].mPosition,player.mCamera.position) > SPRITE_MAX_DISTANCE) // use Chebyshew distance instead Euclidean, it's faster
if (absVal(sprites[i].mPosition.x - player.mCamera.position.x) > SPRITE_MAX_DISTANCE)
continue;
if (absVal(sprites[i].mPosition.y - player.mCamera.position.y) > SPRITE_MAX_DISTANCE)
continue; continue;
PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera); PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera);