diff options
Diffstat (limited to 'src/paperflight/static/util.js')
-rw-r--r-- | src/paperflight/static/util.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/paperflight/static/util.js b/src/paperflight/static/util.js new file mode 100644 index 0000000..f818809 --- /dev/null +++ b/src/paperflight/static/util.js @@ -0,0 +1,16 @@ +/** + * General purpose functions + */ +function isPointInRamp(x, y, ramp) { + var yDelta = (x - ramp.x) * ramp.slope + return ramp.x < x && x < ramp.x + ramp.width && ramp.y < y + yDelta && y + yDelta < ramp.y + ramp.height +} +function isPointInBox(x, y, box) { + return box.x <= x && x <= box.x + box.width && box.y <= y && y <= box.y + box.height +} +function isPlaneInBox(box) { + return isPointInBox(plane.x, plane.y, box) + || isPointInBox(plane.x + plane.width, plane.y, box) + || isPointInBox(plane.x + plane.width, plane.y + plane.height, box) + || isPointInBox(plane.x, plane.y + plane.height, box) +}
\ No newline at end of file |