fixed a NaN bug caused by a zero-width/height hitbox

Also inventory is widened to 10x7 of prev 9x7
This commit is contained in:
minjaesong
2018-11-06 04:02:33 +09:00
parent 5c8cdd3162
commit c7c68187eb
14 changed files with 78 additions and 43 deletions

View File

@@ -288,6 +288,7 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
baseHitboxW = w
hitboxTranslateX = tx
hitboxTranslateY = ty
hitbox.setDimension(w.toDouble(), h.toDouble())
}
fun setPosition(pos: Point2d) = setPosition(pos.x, pos.y)
@@ -1079,8 +1080,10 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
}*/
private inline val submergedRatio: Double
get() = submergedHeight / hitbox.height
get() {
if (hitbox.height == 0.0) throw RuntimeException("Hitbox.height is zero")
return submergedHeight / hitbox.height
}
private inline val submergedVolume: Double
get() = submergedHeight * hitbox.width * hitbox.width
@@ -1538,10 +1541,12 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
actorValue[AVKey.BASEMASS] = value
}
internal val avAcceleration: Double
get() = actorValue.getAsDouble(AVKey.ACCEL)!! *
get() { if (accelMultMovement.isNaN()) println("accelMultMovement: $accelMultMovement")
return actorValue.getAsDouble(AVKey.ACCEL)!! *
(actorValue.getAsDouble(AVKey.ACCELBUFF) ?: 1.0) *
accelMultMovement *
scale.sqrt()
}
internal val avSpeedCap: Double
get() = actorValue.getAsDouble(AVKey.SPEED)!! *
(actorValue.getAsDouble(AVKey.SPEEDBUFF) ?: 1.0) *

View File

@@ -71,6 +71,12 @@ class Hitbox(x1: Double, y1: Double, width: Double, height: Double) {
fun setPosition(x1: Double, y1: Double): Hitbox {
hitboxStart = Point2d(x1, y1)
if (width == 0.0 || height == 0.0) {
println("[Hitbox] width or height is zero, perhaps you want to check it out?")
Thread.currentThread().stackTrace.forEach { println(it) }
}
return this
}
fun setPosition(vector: Vector2) = setPosition(vector.x, vector.y)