at this point i have no fkng clue; at least jumping works

This commit is contained in:
minjaesong
2019-01-22 05:06:56 +09:00
parent ce12ce3566
commit 95b94183ee
2 changed files with 7 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ import net.torvald.terrarum.worlddrawer.WorldCamera
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
import org.dyn4j.geometry.Vector2 import org.dyn4j.geometry.Vector2
import java.util.* import java.util.*
import kotlin.math.pow
/** /**
@@ -550,7 +551,7 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
//applyForce(gravitation) //applyForce(gravitation)
applyForce(Vector2(0.0, 0.01)) applyForce(Vector2(0.0, 0.5) / (Terrarum.PHYS_REF_FPS * delta).pow(0.5))
} }
} }
@@ -650,15 +651,12 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
// displacement relative to the original position // displacement relative to the original position
// s(t) = s_0 + v_0 * t + 0.5at^2 // x = x_0 + v_0 t + 0.5 a t^2 // v_0: old velocity
// s(t) = s_0 + 0.5 * (v_0 + v(t)) * t // x = x_0 + v t - 0.5 a t^2 // v: current velocity
// v(t) = v_0 + at
// v_0 = myV
val t = (Terrarum.PHYS_REF_FPS * delta) val t = (Terrarum.PHYS_REF_FPS * delta)
val v0 = externalV + (controllerMoveV ?: nullVec) val v0 = externalV + (controllerMoveV ?: nullVec)
val vt = v0 + externalA * t v0 += externalA * t
val displacement = (v0 + vt) * 0.5 * t val displacement = v0 * t - externalA * (0.5 * t * t)
externalV += externalA * t
val ccdSteps = minOf(16, (displacement.magnitudeSquared / TILE_SIZE.sqr()).floorInt() + 1) // adaptive val ccdSteps = minOf(16, (displacement.magnitudeSquared / TILE_SIZE.sqr()).floorInt() + 1) // adaptive

View File

@@ -559,7 +559,7 @@ open class ActorHumanoid(
private fun jump(delta: Float) { private fun jump(delta: Float) {
if (jumping) {// && jumpable) { if (jumping) {// && jumpable) {
// increment jump counter // increment jump counter
if (jumpCounter < MAX_JUMP_LENGTH) jumpCounter += 1 / (Terrarum.PHYS_REF_FPS * delta).toFloat() if (jumpCounter < MAX_JUMP_LENGTH) jumpCounter += 1
val timedJumpCharge = jumpFunc(MAX_JUMP_LENGTH, jumpCounter) val timedJumpCharge = jumpFunc(MAX_JUMP_LENGTH, jumpCounter)