mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +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) {
|
||||
val region = textureRegion.get(currentFrame, currentRow)
|
||||
batch.color = colorFilter
|
||||
// batch.color = colorFilter
|
||||
|
||||
//val scale = parentActor.scale.toFloat() // wtf?
|
||||
|
||||
|
||||
@@ -1625,20 +1625,26 @@ open class ActorWithBody : Actor {
|
||||
sprite.render(batch, x - offsetX, y - offsetY, scale.toFloat())
|
||||
}
|
||||
|
||||
/*if (WorldCamera.x >= offendingPad && hitbox.startX < WorldCamera.width) {
|
||||
sprite.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat() + world!!.width * TILE_SIZEF,
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
)
|
||||
}
|
||||
else {
|
||||
sprite.render(batch,
|
||||
(hitbox.startX - offsetX).toFloat(),
|
||||
(hitbox.startY - offsetY).toFloat(),
|
||||
(scale).toFloat()
|
||||
)
|
||||
}*/
|
||||
/*
|
||||
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()
|
||||
)*/
|
||||
}
|
||||
|
||||
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) {
|
||||
val offendingPad = INGAME.world.width.times(TerrarumAppConfiguration.TILE_SIZE) - WorldCamera.width - 1
|
||||
val offendingPad2 = WorldCamera.width + 1
|
||||
|
||||
if (WorldCamera.x >= offendingPad && startX < WorldCamera.width) {
|
||||
drawFun(startX + INGAME.world.width * TILE_SIZEF, startY)
|
||||
}
|
||||
// else if (WorldCamera.x <= offendingPad2 && startX > offendingPad) {
|
||||
// drawFun(startX - INGAME.world.width * TILE_SIZEF, startY)
|
||||
// }
|
||||
else {
|
||||
drawFun(startX , startY)
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
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.IngameInstance
|
||||
import net.torvald.terrarum.Point2i
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.ActorID
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import net.torvald.terrarum.*
|
||||
|
||||
typealias BlockBoxIndex = Int
|
||||
|
||||
@@ -111,6 +108,10 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
// using the actor's hitbox
|
||||
|
||||
|
||||
// wrap x-position
|
||||
val posX = posX fmod world!!.width
|
||||
|
||||
|
||||
// check for existing blocks (and fixtures)
|
||||
var hasCollision = false
|
||||
checkForCollision@
|
||||
|
||||
Reference in New Issue
Block a user