trying to fix phys engine platform tile bug

This commit is contained in:
minjaesong
2022-01-03 22:57:54 +09:00
parent 8502b51396
commit b9bb757a76
5 changed files with 32 additions and 19 deletions

View File

@@ -16,10 +16,10 @@ package=net.torvald.terrarum.modulebasegame
entrypoint=net.torvald.terrarum.modulebasegame.EntryPoint entrypoint=net.torvald.terrarum.modulebasegame.EntryPoint
# Release date in YYYY-MM-DD # Release date in YYYY-MM-DD
releasedate=2017-07-14 releasedate=2022-01-24
# The version, must follow Semver 2.0.0 scheme (https://semver.org/) # The version, must follow Semver 2.0.0 scheme (https://semver.org/)
version=0.2.0 version=0.3.0
# External JAR that the module is compiled. If your module requires yet another library, the JAR must be compiled as a "Fatjar"; # External JAR that the module is compiled. If your module requires yet another library, the JAR must be compiled as a "Fatjar";
# Due to security reasons, loading an arbitrary JAR is not allowed. # Due to security reasons, loading an arbitrary JAR is not allowed.

View File

@@ -6,4 +6,4 @@ entrypoint=net.torvald.terrarum.modulecomputers.EntryPoint
releasedate=2021-12-03 releasedate=2021-12-03
version=0.3.0 version=0.3.0
jar=ModuleComputers.jar jar=ModuleComputers.jar
dependency=basegame 0.2.* dependency=basegame 0.3.0

View File

@@ -1281,24 +1281,39 @@ open class ActorWithBody : Actor {
* Very straightforward for the actual solid tiles, not so much for the platforms * Very straightforward for the actual solid tiles, not so much for the platforms
*/ */
private fun shouldICollideWithThis(tile: ItemID) = private fun shouldICollideWithThis(tile: ItemID) =
// regular solid block // regular solid block
(BlockCodex[tile].isSolid) (BlockCodex[tile].isSolid)
// the location and size of the platform in world coord
protected var platformsToIgnore: Hitbox? = null
private fun standingOnIgnoredPlatform(): Boolean = platformsToIgnore.let {
return if (it != null)
hitbox.startX >= it.startX && hitbox.endX <= it.endX - PHYS_EPSILON_DIST &&
it.startY <= hitbox.endY && hitbox.endY <= it.endY - PHYS_EPSILON_DIST
else false
}
/** /**
* If this tile should be treated as "collidable" * If this tile should be treated as "collidable"
* *
* Just like "shouldICollideWithThis" but it's intended to work with feet tiles * Just like "shouldICollideWithThis" but it's intended to work with feet tiles
*/ */
private fun shouldICollideWithThisFeet(tile: ItemID) = private fun shouldICollideWithThisFeet(tile: ItemID) =
// regular solid block // regular solid block
(BlockCodex[tile].isSolid) || (BlockCodex[tile].isSolid) ||
// platforms, moving downward AND not "going down" // or platforms that are not on the "ignored list" (the list is updated on the update())
(this is ActorHumanoid && BlockCodex[tile].isPlatform && (this is ActorHumanoid && BlockCodex[tile].isPlatform && !standingOnIgnoredPlatform())
externalV.y + (controllerV?.y ?: 0.0) >= 0.0 &&
!this.isDownDown && this.axisY <= 0f) || /*
// platforms, moving downward // platforms, moving downward AND not "going down"
(this !is ActorHumanoid && BlockCodex[tile].isPlatform && (this is ActorHumanoid && BlockCodex[tile].isPlatform &&
externalV.y + (controllerV?.y ?: 0.0) >= 0.0) externalV.y + (controllerV?.y ?: 0.0) >= 0.0 &&
!this.isDownDown && this.axisY <= 0f) ||
// platforms, moving downward
(this !is ActorHumanoid && BlockCodex[tile].isPlatform &&
externalV.y + (controllerV?.y ?: 0.0) >= 0.0)
*/
// TODO: as for the platform, only apply it when it's a feet tile // TODO: as for the platform, only apply it when it's a feet tile

View File

@@ -197,6 +197,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
if (isNoClip) { if (isNoClip) {
//grounded = true //grounded = true
platformsToIgnore = null
} }
// reset control box of AI // reset control box of AI
@@ -498,6 +499,10 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
isWalkingV = true isWalkingV = true
// TODO do something to the ActorWithBody.platformsToIgnore
} }
private fun applyAccel(x: Int): Double { private fun applyAccel(x: Int): Double {

View File

@@ -129,13 +129,6 @@ class ConsoleWindow : UICanvas() {
} }
uiItems.forEach { it.render(batch, camera) } uiItems.forEach { it.render(batch, camera) }
Terrarum.ingame?.let {
batch.color = Color.WHITE
it.actorNowPlaying?.getSpriteHead()!!.let {
batch.draw(it, drawOffX + 10f, drawOffY + height + 4f)
}
}
} }
override fun inputStrobed(e: TerrarumKeyboardEvent) { override fun inputStrobed(e: TerrarumKeyboardEvent) {