mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
minor phys fix
This commit is contained in:
@@ -891,15 +891,15 @@ open class ActorWithBody : Actor {
|
||||
|
||||
// points to the EDGE of the tile in world dimension (don't use this directly to get tilewise coord!!)
|
||||
val offendingTileWorldX = if (selfCollisionStatus in listOf(6, 12))
|
||||
newHitbox.endX.div(TILE_SIZE).floorToDouble() * TILE_SIZE - PHYS_EPSILON_DIST
|
||||
newHitbox.endX.div(TILE_SIZE).floorToDouble() * TILE_SIZE - PHYS_EPSILON_DIST // adding/subbing fixes a bug where player stops midair when L/R is held and moving down from the platform
|
||||
else
|
||||
newHitbox.startX.div(TILE_SIZE).ceilToDouble() * TILE_SIZE
|
||||
newHitbox.startX.div(TILE_SIZE).ceilToDouble() * TILE_SIZE + PHYS_EPSILON_DIST // adding/subbing fixes a bug where player stops midair when L/R is held and moving down from the platform
|
||||
|
||||
// points to the EDGE of the tile in world dimension (don't use this directly to get tilewise coord!!)
|
||||
val offendingTileWorldY = if (selfCollisionStatus in listOf(3, 6))
|
||||
newHitbox.endY.div(TILE_SIZE).floorToDouble() * TILE_SIZE - PHYS_EPSILON_DIST
|
||||
newHitbox.endY.div(TILE_SIZE).floorToDouble() * TILE_SIZE - PHYS_EPSILON_DIST // adding/subbing fixes a bug where player stops midair when L/R is held and moving down from the platform
|
||||
else
|
||||
newHitbox.startY.div(TILE_SIZE).ceilToDouble() * TILE_SIZE
|
||||
newHitbox.startY.div(TILE_SIZE).ceilToDouble() * TILE_SIZE + PHYS_EPSILON_DIST // adding/subbing fixes a bug where player stops midair when L/R is held and moving down from the platform
|
||||
|
||||
val offendingHitboxPointX = if (selfCollisionStatus in listOf(6, 12))
|
||||
newHitbox.endX
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.printStackTrace
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -190,6 +191,15 @@ class Hitbox {
|
||||
companion object {
|
||||
fun fromTwoPoints(x1: Double, y1: Double, x2: Double, y2: Double, nowarn: Boolean = false) =
|
||||
Hitbox(x1, y1, x2 - x1, y2 - y1, nowarn)
|
||||
|
||||
fun lerp(fraction: Double, a: Hitbox, b: Hitbox): Hitbox {
|
||||
return Hitbox(
|
||||
FastMath.interpolateLinear(fraction, a.startX, b.startX),
|
||||
FastMath.interpolateLinear(fraction, a.startY, b.startY),
|
||||
FastMath.interpolateLinear(fraction, a.width, b.width),
|
||||
FastMath.interpolateLinear(fraction, a.height, b.height)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
operator fun minus(other: Hitbox): Vector2 {
|
||||
|
||||
Reference in New Issue
Block a user