From 8489dd810c50d0cb727ada12744896a23933ffd3 Mon Sep 17 00:00:00 2001 From: TheSaminator Date: Sun, 5 Jun 2022 12:20:31 -0400 Subject: [PATCH] Finally fix those NaN errors! --- src/commonMain/kotlin/starshipfights/game/game_ability.kt | 2 +- src/jvmTest/kotlin/starshipfights/game/ai/AITesting.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commonMain/kotlin/starshipfights/game/game_ability.kt b/src/commonMain/kotlin/starshipfights/game/game_ability.kt index 3d23d6a..108c367 100644 --- a/src/commonMain/kotlin/starshipfights/game/game_ability.kt +++ b/src/commonMain/kotlin/starshipfights/game/game_ability.kt @@ -249,7 +249,7 @@ sealed class PlayerAbilityType { if (angleDiff - shipInstance.movement.turnAngle > EPSILON) return GameEvent.InvalidAction("Illegal move - turn angle is too big") val maxMoveSpeed = shipInstance.movement.moveSpeed - val minMoveSpeed = maxMoveSpeed * (angleDiff / shipInstance.movement.turnAngle) / 2 + val minMoveSpeed = if (maxMoveSpeed < EPSILON) maxMoveSpeed else (maxMoveSpeed * (angleDiff / shipInstance.movement.turnAngle) / 2) val moveFrom = moveOrigin + (newFacingNormal * minMoveSpeed) val moveTo = moveOrigin + (newFacingNormal * maxMoveSpeed) diff --git a/src/jvmTest/kotlin/starshipfights/game/ai/AITesting.kt b/src/jvmTest/kotlin/starshipfights/game/ai/AITesting.kt index bf6287e..625279d 100644 --- a/src/jvmTest/kotlin/starshipfights/game/ai/AITesting.kt +++ b/src/jvmTest/kotlin/starshipfights/game/ai/AITesting.kt @@ -12,7 +12,7 @@ import javax.swing.UIManager object AITesting { @JvmStatic fun main(args: Array) { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) + UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel") val instinctVectorCounts = listOf(5, 11, 17) val instinctVectorOptions = instinctVectorCounts.map { it.toString() }.toTypedArray() -- 2.25.1