mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
fixture spawns with correct tex pos and hitbox; unsure if issue #26 is fixed tho
This commit is contained in:
@@ -18,10 +18,12 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
||||
unsafeConstructor.isAccessible = true
|
||||
unsafe = unsafeConstructor.newInstance()
|
||||
}
|
||||
private var unsafeArrayInitialised = false
|
||||
private var unsafeArrayDestroyed = false
|
||||
|
||||
private var layerPtr = unsafe.allocateMemory(width * height * BYTES_PER_BLOCK.toLong())
|
||||
init {
|
||||
unsafe.setMemory(layerPtr, width * height * BYTES_PER_BLOCK.toLong(), 0) // sometimes does not work?!
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data Byte array representation of the layer, where:
|
||||
@@ -39,18 +41,8 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable {
|
||||
*/
|
||||
constructor(width: Int, height: Int, data: ByteArray) : this(width, height) {
|
||||
data.forEachIndexed { index, byte -> unsafe.putByte(layerPtr + index, byte) }
|
||||
unsafeArrayInitialised = true
|
||||
}
|
||||
|
||||
init {
|
||||
if (!unsafeArrayInitialised) {
|
||||
//unsafe.setMemory(layerPtr, width * height * BYTES_PER_BLOCK.toLong(), 0) // sometimes does not work?!
|
||||
for (i in 0 until width * height * BYTES_PER_BLOCK.toLong()) {
|
||||
unsafe.putByte(layerPtr + i, 0)
|
||||
}
|
||||
unsafeArrayInitialised = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator over blocks of type `Int`.
|
||||
|
||||
@@ -31,7 +31,7 @@ internal class FixtureTikiTorch : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1,
|
||||
lightBoxList = ArrayList(1)
|
||||
lightBoxList.add(Hitbox(6.0, 5.0, 4.0, 3.0))
|
||||
|
||||
makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 10, 27))
|
||||
makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 16, 32))
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 1.0
|
||||
|
||||
Reference in New Issue
Block a user