aboutsummaryrefslogtreecommitdiff
path: root/src/paperflight/static/util.js
blob: f818809c9dc8b85789a5b099d7c98c66eff7f14a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)
}