Commit 33c663d9 authored by Minjae Song's avatar Minjae Song

fixture spawns with correct tex pos and hitbox; unsure if issue #26 is fixed tho

parent 44e12825
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment