mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
at this point i have no fkng clue; at least jumping works
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user