equal
deleted
inserted
replaced
|
1 -- Library for miscellaneous utilitiy functions |
|
2 |
|
3 -- Check if a gear is inside a box |
|
4 function gearIsInBox(gear, x, y, w, h) |
|
5 gx, gy = GetGearPosition(gear) |
|
6 if gx >= x and gy >= y and gx <= x + w and gy <= y + h then |
|
7 return true |
|
8 end |
|
9 return false |
|
10 end |
|
11 |
|
12 -- Check if a gear is inside a circle |
|
13 function gearIsInCircle(gear, x, y, r, useRadius) |
|
14 gx, gy = GetGearPosition(gear) |
|
15 if useRadius then |
|
16 r = r + GetGearRadius(gear) |
|
17 end |
|
18 if r ^ 2 >= (x - gx) ^ 2 + (y - gy) ^ 2 then |
|
19 return true |
|
20 end |
|
21 return false |
|
22 end |