mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
actor hit ceiling and now properly bounce back (again, gah!)
Former-commit-id: 05ce5bbae52337a92e26bd6937d610bd2c14cefb Former-commit-id: 810db52f9f9f1756d2d667229487fb653f87898e
This commit is contained in:
@@ -464,7 +464,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
return timedJumpCharge
|
||||
}
|
||||
|
||||
if (jumping) {
|
||||
if (jumping) {// && jumpable) {
|
||||
// increment jump counter
|
||||
if (jumpCounter < len) jumpCounter += 1
|
||||
|
||||
@@ -472,8 +472,13 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
jumpAcc = pwr * timedJumpCharge * JUMP_ACCELERATION_MOD * Math.sqrt(scale) // positive value
|
||||
|
||||
applyForce(Vector2(0.0, -jumpAcc))
|
||||
walkY -= jumpAcc
|
||||
}
|
||||
// not sure we need this...
|
||||
/*else if (!jumpable) {
|
||||
jumpable = true // this is kind of like "semaphore", we toggle it now
|
||||
grounded = false // just in case...
|
||||
}*/
|
||||
|
||||
// release "jump key" of AIs
|
||||
if (jumpCounter >= len && !isGamer) {
|
||||
|
||||
@@ -91,6 +91,8 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
||||
protected set(value) {
|
||||
controllerMoveDelta!!.y = value
|
||||
}
|
||||
// not sure we need this...
|
||||
//var jumpable = true // this is kind of like "semaphore"
|
||||
|
||||
/**
|
||||
* Physical properties.
|
||||
@@ -587,12 +589,22 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
||||
* prevents sticking to the ceiling
|
||||
*/
|
||||
private fun hitAndForciblyReflectY() {
|
||||
println("hitAndForciblyReflectY")
|
||||
// TODO HARK! I have changed veloX/Y to moveDelta.x/y
|
||||
if (moveDelta.y < 0) {
|
||||
if (moveDelta.y.abs() * CEILING_HIT_ELASTICITY > A_PIXEL)
|
||||
walkY = 0.0
|
||||
if (moveDelta.y * CEILING_HIT_ELASTICITY < -A_PIXEL) {
|
||||
moveDelta.y = -moveDelta.y * CEILING_HIT_ELASTICITY
|
||||
else
|
||||
moveDelta.y = moveDelta.y.sign() * -A_PIXEL
|
||||
}
|
||||
else {
|
||||
moveDelta.y = A_PIXEL
|
||||
}
|
||||
|
||||
// for more of a "bounce", you can assign zero if you don't like it
|
||||
externalForce.y = moveDelta.y * CEILING_HIT_ELASTICITY
|
||||
//externalForce.y = 0.0
|
||||
|
||||
nextHitbox.translatePosY(0.5)
|
||||
}
|
||||
else {
|
||||
throw Error("Check this out bitch (moveDelta.y = ${moveDelta.y})")
|
||||
|
||||
Reference in New Issue
Block a user