platform going down with Down button on keeb

This commit is contained in:
Minjae Song
2018-12-30 20:17:28 +09:00
parent bd12cdeab6
commit ba53720b80
2 changed files with 20 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ import net.torvald.terrarum.blockproperties.BlockProp
import net.torvald.terrarum.gamecontroller.KeyToggler
import net.torvald.terrarum.gameworld.BlockAddress
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
import net.torvald.terrarum.worlddrawer.WorldCamera
@@ -967,8 +968,15 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
private fun shouldICollideWithThis(tile: Int) =
// regular solid block
(BlockCodex[tile].isSolid) ||
// platforms and their necessary conditionals
(BlockCodex[tile].isPlatform && externalForce.y + (controllerMoveDelta?.y ?: 0.0) >= 0.0)
// platforms, moving downward AND not "going down"
(this is ActorHumanoid && BlockCodex[tile].isPlatform &&
externalForce.y + (controllerMoveDelta?.y ?: 0.0) >= 0.0 &&
!this.isDownDown && this.axisY <= 0f) ||
// platforms, moving downward
(this !is ActorHumanoid && BlockCodex[tile].isPlatform &&
externalForce.y + (controllerMoveDelta?.y ?: 0.0) >= 0.0)
// TODO: as for the platform, only apply it when it's a feet tile

View File

@@ -13,8 +13,8 @@ import net.torvald.terrarum.itemproperties.GameItem
import net.torvald.terrarum.itemproperties.Material
import net.torvald.terrarum.modulebasegame.Ingame
import net.torvald.terrarum.modulebasegame.gameworld.time_t
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
import net.torvald.terrarum.realestate.LandUtil
import net.torvald.terrarum.worlddrawer.LightmapRenderer
import org.dyn4j.geometry.Vector2
import java.util.*
@@ -105,10 +105,10 @@ open class ActorHumanoid(
// MOVEMENT RELATED FUNCTIONS //
////////////////////////////////
var axisX = 0f
var axisY = 0f
var axisRX = 0f
var axisRY = 0f
var axisX = 0f; protected set
var axisY = 0f; protected set
var axisRX = 0f; protected set
var axisRY = 0f; protected set
/** empirical value. */
@Transient private val JUMP_ACCELERATION_MOD = 51.0 / 10000.0 // (170 * (17/MAX_JUMP_LENGTH)^2) / 10000.0
@@ -141,11 +141,11 @@ open class ActorHumanoid(
@Transient private val AXIS_KEYBOARD = -13372f // leetz
@Transient private val GAMEPAD_JUMP = 7
protected var isUpDown = false
protected var isDownDown = false
protected var isLeftDown = false
protected var isRightDown = false
protected var isJumpDown = false
var isUpDown = false; protected set
var isDownDown = false; protected set
var isLeftDown = false; protected set
var isRightDown = false; protected set
var isJumpDown = false; protected set
protected inline val isGamer: Boolean
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.actorNowPlaying