making wire actor's hitbox bigger so their disappearance on the screen edge won't be visible

This commit is contained in:
minjaesong
2021-07-31 19:13:29 +09:00
parent 5311158ad8
commit 7624e37bda
3 changed files with 16 additions and 4 deletions

View File

@@ -1613,7 +1613,7 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
} }
} }
private fun drawSpriteInGoodPosition(sprite: SpriteAnimation, batch: SpriteBatch) { protected fun drawSpriteInGoodPosition(sprite: SpriteAnimation, batch: SpriteBatch) {
if (world == null) return if (world == null) return

View File

@@ -1,6 +1,8 @@
package net.torvald.terrarum.gameactors package net.torvald.terrarum.gameactors
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.AppLoader.printdbg import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.BlendMode
import net.torvald.terrarum.CommonResourcePool import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.Point2i import net.torvald.terrarum.Point2i
import net.torvald.terrarum.Terrarum import net.torvald.terrarum.Terrarum
@@ -38,6 +40,8 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
* @param itemID must start with "wire@" * @param itemID must start with "wire@"
*/ */
fun setWire(itemID: ItemID, worldX: Int, worldY: Int) { fun setWire(itemID: ItemID, worldX: Int, worldY: Int) {
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0)
if (oldWireId != itemID) { if (oldWireId != itemID) {
if (sprite == null) { if (sprite == null) {
makeNewSprite(CommonResourcePool.getAsTextureRegionPack(itemID)) makeNewSprite(CommonResourcePool.getAsTextureRegionPack(itemID))
@@ -50,7 +54,7 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
} }
this.worldX = worldX this.worldX = worldX
this.worldY = worldY this.worldY = worldY
setPosition(worldX * TILE_SIZE + 1.0, (worldY + 1.0) * TILE_SIZE - 1.0) // what the fuck? setPosition((worldX + 0.5) * TILE_SIZE, (worldY + 1.0) * TILE_SIZE - 1.0) // what the fuck?
sprite!!.currentRow = 1 sprite!!.currentRow = 1
@@ -77,4 +81,10 @@ class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.I
} }
override fun drawBody(batch: SpriteBatch) {
if (isVisible && sprite != null) {
BlendMode.resolve(drawMode, batch)
drawSpriteInGoodPosition(sprite!!, batch)
}
}
} }

View File

@@ -80,6 +80,8 @@ class BasicDebugInfoWindow : UICanvas() {
val hitbox = player?.hitbox val hitbox = player?.hitbox
val updateCount = maxOf(1L, (AppLoader.debugTimers["Ingame.UpdateCounter"] ?: 1L) as Long)
/** /**
* First column * First column
*/ */
@@ -123,8 +125,8 @@ class BasicDebugInfoWindow : UICanvas() {
printLine(batch, 5, "p_WalkX $ccG${player.controllerV?.x}") printLine(batch, 5, "p_WalkX $ccG${player.controllerV?.x}")
printLine(batch, 6, "p_WalkY $ccG${player.controllerV?.y}") printLine(batch, 6, "p_WalkY $ccG${player.controllerV?.y}")
printLineColumn(batch, 2, 3, "veloX measured $ccG${xdelta}") printLineColumn(batch, 2, 3, "veloX measured $ccG${xdelta / updateCount}")
printLineColumn(batch, 2, 4, "veloY measured $ccG${ydelta}") printLineColumn(batch, 2, 4, "veloY measured $ccG${ydelta / updateCount}")
printLineColumn(batch, 1, 7, printLineColumn(batch, 1, 7,
"walled " + "walled " +