Jump to content

Little issue when drawing race pickups in a race radar


xPipeZ

Recommended Posts

Hello everyone, I am currently developing a small radar for racing but I ran into a small problem that I have not been able to solve

When I'm drawing the blips on the radar for the race checkpoints, it literally draws all of them and not just the first two, which are the ones that are visible to the player

Here is my part of the code where I am doing this, thanks in advance

for i, checkpoint in ipairs(getElementsByType("checkpoint")) do
  local cpx = getElementData(checkpoint, "posX");
  local cpy = getElementData(checkpoint, "posY");
  local dist = getDistanceBetweenPoints2D(px, py, cpx, cpy);
  if dist > range then
    dist = range;
  end
  local angle = 180 - north + findRotation(px, py, cpx, cpy);
  local cbx, cby = getPointFromDistanceRotation(0, 0, size * (dist / range) / 2, angle);
  local bx = centerLeft + cbx - blipSize/2;
  local by = centerTop + cby - blipSize/2;
  local yoff = 0;
  local r, g, b, a = getColorFromString(getElementData(checkpoint, "color"));
  local img = "assets/images/checkpoint.png";
  dxDrawImage(bx, by, blipSize, blipSize, img, 0, 0, 0, tocolor(r, g, b, a));
end

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...