index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <Catalin.Mititiuc@gmail.com> | 2024-03-22 16:58:12 -0700 |
---|---|---|
committer | Catalin Mititiuc <Catalin.Mititiuc@gmail.com> | 2024-03-22 16:58:12 -0700 |
commit | 7d9073eebf14e9dfb74799fa6c6658b904051ed2 (patch) | |
tree | 821178836d9a8f00f97fdea3413aeb8e8c9a7856 | |
parent | e6cc5d687e29481f9bdb3423e13f77f856c41aa5 (diff) |
Add some symmetry to edge point calculation function
-rw-r--r-- | index.js | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -30,21 +30,19 @@ function edgePoint(x1, y1, x2, y2, maxX, maxY) { let yWhenXisMax = yIntercept(maxX); let xWhenYisZero = xIntercept(0); - if (xWhenYisZero <= maxX) { - // yWhenXisMax - pointCoords = [xWhenYisZero, 0]; - } else { + if (yWhenXisMax >= 0) { pointCoords = [maxX, yWhenXisMax]; + } else { + pointCoords = [xWhenYisZero, 0]; } } else if (xDiff < 0 && yDiff < 0) { let yWhenXisZero = yIntercept(0); let xWhenYisZero = xIntercept(0); - if (yWhenXisZero >= 0) { - // xWhenYisZero - pointCoords = [0, yWhenXisZero]; - } else { + if (xWhenYisZero >= 0) { pointCoords = [xWhenYisZero, 0]; + } else { + pointCoords = [0, yWhenXisZero]; } } else { let yWhenXisZero = yIntercept(0); |