diff --git a/src/net/torvald/spriteanimation/SpriteAnimation.kt b/src/net/torvald/spriteanimation/SpriteAnimation.kt index e2a08f1d5..a54358017 100644 --- a/src/net/torvald/spriteanimation/SpriteAnimation.kt +++ b/src/net/torvald/spriteanimation/SpriteAnimation.kt @@ -128,7 +128,7 @@ class SpriteAnimation(@Transient val parentActor: ActorWithBody) { if (visible) { val region = textureRegion.get(currentFrame, currentRow) - batch.color = colorFilter +// batch.color = colorFilter //val scale = parentActor.scale.toFloat() // wtf? diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index a9569cb55..becf26ad8 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -1620,12 +1620,14 @@ open class ActorWithBody : Actor { val leftsidePadding = world!!.width.times(TILE_SIZE) - WorldCamera.width.ushr(1) val rightsidePadding = WorldCamera.width.ushr(1) + val offendingPad = world!!.width.times(TILE_SIZE) - WorldCamera.width.ushr(1) + val offsetX = hitboxTranslateX * scale val offsetY = sprite.cellHeight * scale - hitbox.height - hitboxTranslateY * scale - 1 // it would be great if you can eliminate the try-catch because it may hurt the performance when there's too many actors on screen to draw // try { - if (Math.abs(WorldCamera.x - hitbox.startX) > App.scr.halfw) { + /*if (Math.abs(WorldCamera.x - hitbox.startX) > App.scr.halfw) { sprite.render(batch, (hitbox.startX - offsetX).toFloat() + world!!.width * TILE_SIZEF, (hitbox.startY - offsetY).toFloat(), @@ -1638,7 +1640,30 @@ open class ActorWithBody : Actor { (hitbox.startY - offsetY).toFloat(), (scale).toFloat() ) - } + }*/ + batch.color = Color.WHITE + sprite.render(batch, + (hitbox.startX - offsetX).toFloat(), + (hitbox.startY - offsetY).toFloat(), + (scale).toFloat() + ) + + batch.color = Color.BLUE + sprite.render(batch, + (hitbox.startX - offsetX).toFloat() - world!!.width * TILE_SIZEF, + (hitbox.startY - offsetY).toFloat(), + (scale).toFloat() + ) + + batch.color = Color.GREEN + sprite.render(batch, + (hitbox.startX - offsetX).toFloat() + world!!.width * TILE_SIZEF, + (hitbox.startY - offsetY).toFloat(), + (scale).toFloat() + ) + + + // } // catch (e: UninitializedPropertyAccessException) { // printdbgerr(this, this.javaClass.simpleName) @@ -1681,10 +1706,10 @@ open class ActorWithBody : Actor { } private fun clampWtile(x: Int): Int = - if (x < 0) 0 else if (x >= world?.width ?: 0) (world?.width ?: 0) - 1 else x + if (x < 0) 0 else if (x >= (world?.width ?: 0)) (world?.width ?: 0) - 1 else x private fun clampHtile(x: Int): Int = - if (x < 0) 0 else if (x >= world?.height ?: 0) (world?.height ?: 0) - 1 else x + if (x < 0) 0 else if (x >= (world?.height ?: 0)) (world?.height ?: 0) - 1 else x var isNoClip: Boolean = false diff --git a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt index bb4edd8d6..90d2f1db3 100644 --- a/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt +++ b/src/net/torvald/terrarum/modulebasegame/TerrarumIngame.kt @@ -572,6 +572,7 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { } private var worldWidth: Double = 0.0 + private var oldCamX = 0 /** * Ingame (world) related updates; UI update must go to renderGame() @@ -633,13 +634,17 @@ open class TerrarumIngame(batch: SpriteBatch) : IngameInstance(batch) { BlockStats.update() } // fill up visibleActorsRenderFront for wires, if: - // 1. something is cued on the wire change queue - // 2. wire renderclass changed - if (newWorldLoadedLatch || wireChangeQueue.isNotEmpty() || selectedWireRenderClass != oldSelectedWireRenderClass) { + // 0. Camera wrapped + // 1. new world has been loaded + // 2. something is cued on the wire change queue + // 3. wire renderclass changed + if (Math.abs(WorldCamera.x - oldCamX) >= worldWidth * 0.85 || + newWorldLoadedLatch || wireChangeQueue.isNotEmpty() || selectedWireRenderClass != oldSelectedWireRenderClass) { measureDebugTime("Ingame.FillUpWiresBuffer") { fillUpWiresBuffer() } } + oldCamX = WorldCamera.x }