hexyz is tower defense game, and a lua library for dealing with hexagonal grids
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
681 B

  1. function circles_intersect(center1, center2, radius1, radius2)
  2. local c1, c2, r1, r2 = center1, center2, radius1, radius2
  3. local d = math.distance(center1, center2)
  4. local radii_sum = r1 + r2
  5. -- touching
  6. if d == radii_sum then return 1
  7. -- not touching or intersecting
  8. elseif d > radii_sum then return false
  9. -- intersecting
  10. else return 2
  11. end
  12. end
  13. function point_in_rect(point, rect)
  14. return point.x > rect.x1
  15. and point.x < rect.x2
  16. and point.y > rect.y1
  17. and point.y < rect.y2
  18. end