From 0b0ade51b8793d2c4706a093cb9bb9944d4ab6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Thu, 6 Sep 2018 09:40:40 +0200 Subject: [PATCH] Add sprite distance --- game.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/game.cpp b/game.cpp index bb3cdac..372a07b 100644 --- a/game.cpp +++ b/game.cpp @@ -26,6 +26,7 @@ #define MIDDLE_COLUMN (SCREEN_WIDTH / 2) #define SPRITES 3 +#define SPRITE_MAX_DISTANCE 5 * UNITS_PER_SQUARE Pokitto::Core p; @@ -699,6 +700,9 @@ void draw() for (uint8_t i = 0; i < SPRITES; ++i) { + if (dist(sprites[i].mPosition,player.mCamera.position) > SPRITE_MAX_DISTANCE) + continue; + PixelInfo pos = mapToScreen(sprites[i].mPosition,sprites[i].mHeight,player.mCamera); if (pos.depth > 0)