mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Add divide by zero check'
This commit is contained in:
parent
796c35f66d
commit
41cf864dc7
1 changed files with 4 additions and 1 deletions
|
@ -365,7 +365,10 @@ module.exports = class CampaignView extends RootView
|
|||
return experienceScore
|
||||
|
||||
createLine: (o1, o2) ->
|
||||
ratio = parseFloat($(".map").css("width")) / parseFloat($(".map").css("height"))
|
||||
mapHeight = parseFloat($(".map").css("height"))
|
||||
mapWidth = parseFloat($(".map").css("width"))
|
||||
return unless mapHeight > 0
|
||||
ratio = mapWidth / mapHeight
|
||||
p1 = x: o1.x, y: o1.y / ratio - 0.5
|
||||
p2 = x: o2.x, y: o2.y / ratio
|
||||
length = Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y))
|
||||
|
|
Loading…
Reference in a new issue