actor hit ceiling and now properly bounce back (again, gah!)

Former-commit-id: 05ce5bbae52337a92e26bd6937d610bd2c14cefb
Former-commit-id: 810db52f9f9f1756d2d667229487fb653f87898e
This commit is contained in:
Song Minjae
2017-02-26 03:07:54 +09:00
parent 6c2a411ee2
commit 5861161261
2 changed files with 22 additions and 5 deletions

View File

@@ -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) {

View File

@@ -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})")