From dff8dee815d84bf408caf9269159717304154a7d Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 12 Feb 2018 08:32:21 +0000 Subject: [PATCH] Clip visible entities. --- src/world/radar.c | 14 ++++++++++---- src/world/radar.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/world/radar.c b/src/world/radar.c index 81453dc..02eec9c 100644 --- a/src/world/radar.c +++ b/src/world/radar.c @@ -122,12 +122,18 @@ static void drawEntities(void) { if (isValidBlip(e)) { - x = (e->x / MAP_TILE_SIZE) - viewRect.x; - y = (e->y / MAP_TILE_SIZE) - viewRect.y; + x = (e->x / MAP_TILE_SIZE); + y = (e->y / MAP_TILE_SIZE); - getBlipColor(e, &c); + if (x >= viewRect.x && x < viewRect.x + viewRect.w && y >= viewRect.y && y < viewRect.y + viewRect.h) + { + x -= viewRect.x; + y -= viewRect.y; + + getBlipColor(e, &c); - drawRect(OFFSET_X + (x * RADAR_TILE_SIZE), OFFSET_Y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, c.r, c.g, c.b, 255); + drawRect(OFFSET_X + (x * RADAR_TILE_SIZE), OFFSET_Y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, c.r, c.g, c.b, 255); + } } } } diff --git a/src/world/radar.h b/src/world/radar.h index 1c360d6..4c5a571 100644 --- a/src/world/radar.h +++ b/src/world/radar.h @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define RADAR_TILE_SIZE 16 -#define VIEW_SIZE 60 +#define VIEW_SIZE 40 #define OFFSET_X ((SCREEN_WIDTH - (RADAR_TILE_SIZE * VIEW_SIZE)) / 2) #define OFFSET_Y ((SCREEN_HEIGHT - (RADAR_TILE_SIZE * VIEW_SIZE)) / 2)