fixed camera not putting actor at the centre of the screen

- Actually may not be fixed, but it does not cause render bugs at least!
This commit is contained in:
minjaesong
2017-09-17 23:42:13 +09:00
parent edb1ea384f
commit 108a44d970
6 changed files with 68 additions and 45 deletions

View File

@@ -405,8 +405,6 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
displaceHitbox()
//applyNormalForce()
//applyControllerMoveVelo() // TODO
}
else {
hitbox.translate(externalForce)
@@ -1148,11 +1146,22 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
private fun clampHitbox() {
val worldsizePxl = world.width.times(TILE_SIZE)
// DEAR FUTURE ME,
//
// this code potentially caused a collision bug which only happens near the "edge" of the world.
//
// -- Signed, 2017-09-17
// wrap around for X-axis
val actorMinimumX = Terrarum.HALFW // to make camera's X stay positive
val actorMaximumX = worldsizePxl + actorMinimumX // to make camera's X stay positive
hitbox.setPositionFromPointed(
//clampW(hitbox.canonicalX),
if (hitbox.canonicalX < 0)
if (hitbox.canonicalX < actorMinimumX)
hitbox.canonicalX + worldsizePxl
else if (hitbox.canonicalX >= worldsizePxl)
else if (hitbox.canonicalX >= actorMaximumX)
hitbox.canonicalX - worldsizePxl
else
hitbox.canonicalX, // ROUNDWORLD impl