wire actor renders; functionality still wip

This commit is contained in:
minjaesong
2021-07-31 14:18:46 +09:00
parent f64574db80
commit b10fb0a30b
8 changed files with 106 additions and 40 deletions

View File

@@ -214,9 +214,13 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
(world!!.gravitation.y > 0 && isWalled(hitbox, COLLIDING_BOTTOM) ||
world!!.gravitation.y < 0 && isWalled(hitbox, COLLIDING_TOP))
}
/** Default to 'true' */
/**
* Toggles rendering
* Default to 'true' */
var isVisible = true
/** Default to 'true' */
/**
* Toggles the actual update
* Default to 'true' */
var isUpdate = true
var isNoSubjectToGrav = false
var isNoCollideWorld = false
@@ -230,6 +234,11 @@ open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties)
*/
var isChronostasis = false
/**
* if set to TRUE, the ingame will not move the actor into the active list
*/
var forceDormant = false
/**
* Gravitational Constant G. Load from gameworld.
* [m / s^2]

View File

@@ -1,10 +1,44 @@
package net.torvald.terrarum.gameactors
import net.torvald.terrarum.CommonResourcePool
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
import net.torvald.terrarum.gameitem.ItemID
/**
* Created by minjaesong on 2021-07-30.
*/
class WireActor(id: ActorID) : ActorWithBody(RenderOrder.WIRES, PhysProperties.IMMOBILE) {
init {
this.referenceID = id
referenceID = id
setHitboxDimension(2, 2, 0, 0)
}
private var oldWireId = ""
/**
* @param itemID must start with "wire@"
*/
fun setWire(itemID: ItemID, worldX: Int, worldY: Int) {
if (oldWireId != itemID) {
if (sprite == null) {
makeNewSprite(CommonResourcePool.getAsTextureRegionPack(itemID))
sprite!!.delays = floatArrayOf(1f,1f)
sprite!!.setRowsAndFrames(2, 16)
}
else sprite!!.setSpriteImage(CommonResourcePool.getAsTextureRegionPack(itemID))
oldWireId = itemID
}
setPosition(worldX * TILE_SIZE + 1.0, (worldY + 1.0) * TILE_SIZE - 1.0) // what the fuck?
sprite!!.currentRow = 1
sprite!!.currentFrame = 15
}
override fun update(delta: Float) {
// set autotiling here
// hint: manipulate `sprite!!.currentFrame`
}
}