mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
fixed a bug where spawned fixture's x-position is not wrapped as it should do
This commit is contained in:
@@ -128,7 +128,7 @@ class SpriteAnimation(@Transient val parentActor: ActorWithBody) {
|
|||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
val region = textureRegion.get(currentFrame, currentRow)
|
val region = textureRegion.get(currentFrame, currentRow)
|
||||||
batch.color = colorFilter
|
// batch.color = colorFilter
|
||||||
|
|
||||||
//val scale = parentActor.scale.toFloat() // wtf?
|
//val scale = parentActor.scale.toFloat() // wtf?
|
||||||
|
|
||||||
|
|||||||
@@ -1625,20 +1625,26 @@ open class ActorWithBody : Actor {
|
|||||||
sprite.render(batch, x - offsetX, y - offsetY, scale.toFloat())
|
sprite.render(batch, x - offsetX, y - offsetY, scale.toFloat())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (WorldCamera.x >= offendingPad && hitbox.startX < WorldCamera.width) {
|
/*
|
||||||
sprite.render(batch,
|
sprite.render(batch,
|
||||||
(hitbox.startX - offsetX).toFloat() + world!!.width * TILE_SIZEF,
|
(hitbox.startX - offsetX).toFloat(),
|
||||||
(hitbox.startY - offsetY).toFloat(),
|
(hitbox.startY - offsetY).toFloat(),
|
||||||
(scale).toFloat()
|
(scale).toFloat()
|
||||||
)
|
)
|
||||||
}
|
|
||||||
else {
|
batch.color = Color.BLUE
|
||||||
sprite.render(batch,
|
sprite.render(batch,
|
||||||
(hitbox.startX - offsetX).toFloat(),
|
(hitbox.startX - offsetX).toFloat() - world!!.width * TILE_SIZEF,
|
||||||
(hitbox.startY - offsetY).toFloat(),
|
(hitbox.startY - offsetY).toFloat(),
|
||||||
(scale).toFloat()
|
(scale).toFloat()
|
||||||
)
|
)
|
||||||
}*/
|
|
||||||
|
batch.color = Color.GREEN
|
||||||
|
sprite.render(batch,
|
||||||
|
(hitbox.startX - offsetX).toFloat() + world!!.width * TILE_SIZEF,
|
||||||
|
(hitbox.startY - offsetY).toFloat(),
|
||||||
|
(scale).toFloat()
|
||||||
|
)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActorValueChange(key: String, value: Any?) {
|
override fun onActorValueChange(key: String, value: Any?) {
|
||||||
@@ -1923,10 +1929,14 @@ open class ActorWithBody : Actor {
|
|||||||
|
|
||||||
inline fun drawBodyInGoodPosition(startX: Float, startY: Float, drawFun: (x: Float, y: Float) -> Unit) {
|
inline fun drawBodyInGoodPosition(startX: Float, startY: Float, drawFun: (x: Float, y: Float) -> Unit) {
|
||||||
val offendingPad = INGAME.world.width.times(TerrarumAppConfiguration.TILE_SIZE) - WorldCamera.width - 1
|
val offendingPad = INGAME.world.width.times(TerrarumAppConfiguration.TILE_SIZE) - WorldCamera.width - 1
|
||||||
|
val offendingPad2 = WorldCamera.width + 1
|
||||||
|
|
||||||
if (WorldCamera.x >= offendingPad && startX < WorldCamera.width) {
|
if (WorldCamera.x >= offendingPad && startX < WorldCamera.width) {
|
||||||
drawFun(startX + INGAME.world.width * TILE_SIZEF, startY)
|
drawFun(startX + INGAME.world.width * TILE_SIZEF, startY)
|
||||||
}
|
}
|
||||||
|
// else if (WorldCamera.x <= offendingPad2 && startX > offendingPad) {
|
||||||
|
// drawFun(startX - INGAME.world.width * TILE_SIZEF, startY)
|
||||||
|
// }
|
||||||
else {
|
else {
|
||||||
drawFun(startX , startY)
|
drawFun(startX , startY)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
package net.torvald.terrarum.modulebasegame.gameactors
|
package net.torvald.terrarum.modulebasegame.gameactors
|
||||||
|
|
||||||
import net.torvald.terrarum.App
|
import net.torvald.terrarum.*
|
||||||
import net.torvald.terrarum.App.printdbg
|
import net.torvald.terrarum.App.printdbg
|
||||||
import net.torvald.terrarum.IngameInstance
|
|
||||||
import net.torvald.terrarum.Point2i
|
|
||||||
import net.torvald.terrarum.Terrarum
|
|
||||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.gameactors.ActorID
|
import net.torvald.terrarum.gameactors.ActorID
|
||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.gameactors.PhysProperties
|
import net.torvald.terrarum.gameactors.PhysProperties
|
||||||
import net.torvald.terrarum.gameitem.ItemID
|
import net.torvald.terrarum.gameitem.ItemID
|
||||||
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
import net.torvald.terrarum.ui.UICanvas
|
import net.torvald.terrarum.ui.UICanvas
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
import net.torvald.terrarum.*
|
|
||||||
|
|
||||||
typealias BlockBoxIndex = Int
|
typealias BlockBoxIndex = Int
|
||||||
|
|
||||||
@@ -111,6 +108,10 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
|||||||
// using the actor's hitbox
|
// using the actor's hitbox
|
||||||
|
|
||||||
|
|
||||||
|
// wrap x-position
|
||||||
|
val posX = posX fmod world!!.width
|
||||||
|
|
||||||
|
|
||||||
// check for existing blocks (and fixtures)
|
// check for existing blocks (and fixtures)
|
||||||
var hasCollision = false
|
var hasCollision = false
|
||||||
checkForCollision@
|
checkForCollision@
|
||||||
|
|||||||
Reference in New Issue
Block a user