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,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);
}
}
}
}

View File

@ -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)