Clip visible entities.

This commit is contained in:
Steve 2018-02-12 08:32:21 +00:00
parent 26858489b9
commit dff8dee815
2 changed files with 11 additions and 5 deletions

View File

@ -122,8 +122,13 @@ static void drawEntities(void)
{ {
if (isValidBlip(e)) if (isValidBlip(e))
{ {
x = (e->x / MAP_TILE_SIZE) - viewRect.x; x = (e->x / MAP_TILE_SIZE);
y = (e->y / MAP_TILE_SIZE) - viewRect.y; y = (e->y / MAP_TILE_SIZE);
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); getBlipColor(e, &c);
@ -131,6 +136,7 @@ static void drawEntities(void)
} }
} }
} }
}
static int isValidBlip(Entity *e) static int isValidBlip(Entity *e)
{ {

View File

@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#define RADAR_TILE_SIZE 16 #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_X ((SCREEN_WIDTH - (RADAR_TILE_SIZE * VIEW_SIZE)) / 2)
#define OFFSET_Y ((SCREEN_HEIGHT - (RADAR_TILE_SIZE * VIEW_SIZE)) / 2) #define OFFSET_Y ((SCREEN_HEIGHT - (RADAR_TILE_SIZE * VIEW_SIZE)) / 2)