Guest User

Radar HUD calculation

a guest
Apr 14th, 2023
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. for i = 1, max_targets do
  2.         if targets[i] then
  3.             -- calculate radar's values in radians
  4.             azi_rad = target_azi[i] * pi2
  5.             ele_rad = target_ele[i] * pi2
  6.            
  7.             -- local "unrotated" values
  8.             target_x_unrot = math.sin(azi_rad)
  9.             target_y_unrot = math.cos(ele_rad)
  10.            
  11.             -- rotate the radar values around the roll and pitch
  12.             target_x = ((target_x_unrot * math.cos(roll)) + (target_y_unrot * math.sin(roll))) * target_dst[i]
  13.             target_y = (-(target_x_unrot * math.sin(pitch)) + (target_y_unrot * math.cos(pitch))) * target_dst[i]
  14.    
  15.             -- idk why those numbers are like this, but this is the least f.cky solution
  16.             target_px = ((w/2) - target_x/2)
  17.             target_py = (target_y/2)
  18.  
  19.             -- draw the point on the screen where the enemy should be
  20.             screen.setColor(255, 0, 0)
  21.             screen.drawCircle(target_px, target_py, 2)  -- target point
  22.        
  23.             target_count = target_count + 1 -- update target cnt
  24.         end
  25.     end
Advertisement
Add Comment
Please, Sign In to add comment