diff --git a/demo1.cpp b/demo1.cpp index 11181e9..d4b2e11 100644 --- a/demo1.cpp +++ b/demo1.cpp @@ -7,6 +7,7 @@ license: CC0 1.0 */ +// redefine player's height #define CAMERA_COLL_HEIGHT_BELOW ((3 * UNITS_PER_SQUARE) / 2) #include "general.hpp" @@ -665,7 +666,11 @@ void draw() 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; PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera);