sprites can be rendered across the world seam

This commit is contained in:
minjaesong
2021-09-17 22:54:55 +09:00
parent 58be058b86
commit 575ed4410b
47 changed files with 150 additions and 166 deletions

View File

@@ -161,7 +161,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
var isJumpDown = false; protected set
var isJumpJustDown = false; protected set // TODO if jump key is held in current update frame
protected inline val isGamer: Boolean
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.actorNowPlaying
get() = if (Terrarum.ingame == null) false else this == INGAME.actorNowPlaying
private var jumpJustPressedLatched = false

View File

@@ -139,7 +139,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
this.hitbox.setFromWidthHeight(posX * TILE_SIZED, posY * TILE_SIZED, blockBox.width * TILE_SIZED, blockBox.height * TILE_SIZED)
// actually add this actor into the world
Terrarum.ingame!!.addNewActor(this)
INGAME.addNewActor(this)
return true

View File

@@ -81,7 +81,7 @@ internal class UIStorageChest : UICanvas(
override fun getNegotiator() = negotiator
override fun getFixtureInventory(): FixtureInventory = chestInventory
override fun getPlayerInventory(): FixtureInventory = Terrarum.ingame!!.actorNowPlaying!!.inventory
override fun getPlayerInventory(): FixtureInventory = INGAME.actorNowPlaying!!.inventory
private lateinit var catBar: UIItemInventoryCatBar
private lateinit var itemListChest: UIItemInventoryItemGrid
@@ -151,7 +151,7 @@ internal class UIStorageChest : UICanvas(
itemListPlayer = UIItemInventoryItemGrid(
this,
catBar,
{ Terrarum.ingame!!.actorNowPlaying!!.inventory }, // literally a player's inventory
{ INGAME.actorNowPlaying!!.inventory }, // literally a player's inventory
INVENTORY_CELLS_OFFSET_X - halfSlotOffset + (listGap + UIItemInventoryElem.height) * 7,
INVENTORY_CELLS_OFFSET_Y,
6, CELLS_VRT,

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.modulebasegame.gameactors
import net.torvald.terrarum.INGAME
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.gameactors.AIControlled
import net.torvald.terrarum.gameactors.AVKey
@@ -52,7 +53,7 @@ open class HumanoidNPC : ActorHumanoid, AIControlled, CanBeAnItem {
try {
// place the actor to the world
this@HumanoidNPC.setPosition(Terrarum.mouseX, Terrarum.mouseY)
Terrarum.ingame!!.addNewActor(this@HumanoidNPC)
INGAME.addNewActor(this@HumanoidNPC)
// successful
return true
}

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import net.torvald.terrarum.INGAME
import net.torvald.terrarum.Terrarum
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.gameactors.ActorWithBody
@@ -33,13 +34,13 @@ class PhysTestBall : ActorWithBody(RenderOrder.MIDDLE, PhysProperties.PHYSICS_OB
)
it.circle(
hitbox.startX.toFloat() + (Terrarum.ingame!!.world).width * TILE_SIZE - 1f,
hitbox.startX.toFloat() + (INGAME.world).width * TILE_SIZE - 1f,
hitbox.startY.toFloat() - 1f,
hitbox.width.toFloat()
)
it.circle(
hitbox.startX.toFloat() - (Terrarum.ingame!!.world).width * TILE_SIZE - 1f,
hitbox.startX.toFloat() - (INGAME.world).width * TILE_SIZE - 1f,
hitbox.startY.toFloat() - 1f,
hitbox.width.toFloat()
)

View File

@@ -83,7 +83,7 @@ open class ProjectileSimple : ActorWithBody, Luminous, Projectile {
lifetimeCounter += delta
if (walledTop || walledBottom || walledRight || walledLeft || lifetimeCounter >= lifetimeMax ||
// stuck check
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(feetPosTile.x, feetPosTile.y) ?: Block.STONE].isSolid
BlockCodex[(INGAME.world).getTileFromTerrain(feetPosTile.x, feetPosTile.y) ?: Block.STONE].isSolid
) {
flagDespawn()
}
@@ -103,13 +103,13 @@ open class ProjectileSimple : ActorWithBody, Luminous, Projectile {
/*batch.end()
Terrarum.inShapeRenderer {
// draw trail of solid colour (Terraria style maybe?)
it.lineWidth = 2f * Terrarum.ingame!!.screenZoom
it.lineWidth = 2f * INGAME.screenZoom
g.drawGradientLine(
hitbox.centeredX.toFloat() * Terrarum.ingame!!.screenZoom,
hitbox.centeredY.toFloat() * Terrarum.ingame!!.screenZoom,
hitbox.centeredX.toFloat() * INGAME.screenZoom,
hitbox.centeredY.toFloat() * INGAME.screenZoom,
displayColour,
posPre.x.toFloat() * Terrarum.ingame!!.screenZoom,
posPre.y.toFloat() * Terrarum.ingame!!.screenZoom,
posPre.x.toFloat() * INGAME.screenZoom,
posPre.y.toFloat() * INGAME.screenZoom,
colourTail
)
}

View File

@@ -11,7 +11,7 @@ import net.torvald.terrarum.*
class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Callable<Unit> {
override fun call() {
for (i in startIndex..endIndex) {
val it = Terrarum.ingame!!.actorContainerActive[i]
val it = INGAME.actorContainerActive[i]
it.update(App.UPDATE_RATE)
if (it is Pocketed) {