mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 13:04:05 +09:00
discarding the idea of baking assembledsprite onto a spritesheet; revert to the commit right before this to completely scrap the efforts
This commit is contained in:
@@ -4,7 +4,9 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.spriteanimation.AssembledSpriteAnimation
|
||||
import net.torvald.spriteanimation.HasAssembledSprite
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
@@ -722,8 +724,14 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
|
||||
if (walledBottom && controllerV?.x != 0.0) {
|
||||
//switch row
|
||||
sprite?.switchRow(SPRITE_ROW_WALK)
|
||||
spriteGlow?.switchRow(SPRITE_ROW_WALK)
|
||||
if (this is HasAssembledSprite) {
|
||||
(sprite as? AssembledSpriteAnimation)?.currentAnimation = "ANIM_RUN"
|
||||
(spriteGlow as? AssembledSpriteAnimation)?.currentAnimation = "ANIM_RUN"
|
||||
}
|
||||
else {
|
||||
(sprite as? SheetSpriteAnimation)?.switchRow(SPRITE_ROW_WALK)
|
||||
(spriteGlow as? SheetSpriteAnimation)?.switchRow(SPRITE_ROW_WALK)
|
||||
}
|
||||
|
||||
// set anim frame delay
|
||||
if (this is HasAssembledSprite) {
|
||||
@@ -736,8 +744,8 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
|
||||
val finalDelay = baseDelay * (scaleCompensation / moveSpeedMult)
|
||||
|
||||
sprite?.delays?.set(SPRITE_ROW_WALK, finalDelay)
|
||||
spriteGlow?.delays?.set(SPRITE_ROW_WALK, finalDelay)
|
||||
(sprite as? AssembledSpriteAnimation)?.overrideDelay = finalDelay
|
||||
(spriteGlow as? AssembledSpriteAnimation)?.overrideDelay = finalDelay
|
||||
}
|
||||
catch (e: NullPointerException) {
|
||||
println(animDesc!!.animations.keys.joinToString())
|
||||
@@ -757,8 +765,17 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
}
|
||||
}
|
||||
else {
|
||||
sprite?.switchRow(SPRITE_ROW_IDLE)
|
||||
spriteGlow?.switchRow(SPRITE_ROW_IDLE)
|
||||
|
||||
if (this is HasAssembledSprite) {
|
||||
(sprite as? AssembledSpriteAnimation)?.currentAnimation = "ANIM_IDLE"
|
||||
(spriteGlow as? AssembledSpriteAnimation)?.currentAnimation = "ANIM_IDLE"
|
||||
(sprite as? AssembledSpriteAnimation)?.overrideDelay = 0f
|
||||
(spriteGlow as? AssembledSpriteAnimation)?.overrideDelay = 0f
|
||||
}
|
||||
else {
|
||||
(sprite as? SheetSpriteAnimation)?.switchRow(SPRITE_ROW_IDLE)
|
||||
(spriteGlow as? SheetSpriteAnimation)?.switchRow(SPRITE_ROW_IDLE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,9 @@ class FixtureLogicSignalEmitter : FixtureBase, Electric {
|
||||
density = 1400.0
|
||||
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, -1)
|
||||
|
||||
makeNewSprite(TextureRegionPack(itemImage.texture, TILE_SIZE, TILE_SIZE))
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
makeNewSprite(TextureRegionPack(itemImage.texture, TILE_SIZE, TILE_SIZE)).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = MASS
|
||||
}
|
||||
|
||||
@@ -40,8 +40,9 @@ internal class FixtureStorageChest : FixtureBase {
|
||||
|
||||
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, -1)
|
||||
|
||||
makeNewSprite(TextureRegionPack(CommonResourcePool.getAsTextureRegion("itemplaceholder_16").texture, 16, 16))
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
makeNewSprite(TextureRegionPack(CommonResourcePool.getAsTextureRegion("itemplaceholder_16").texture, 16, 16)).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = MASS
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.ModMgr
|
||||
@@ -52,8 +53,9 @@ internal class FixtureTikiTorch : FixtureBase, Luminous {
|
||||
|
||||
lightBoxList.add(Lightbox(Hitbox(6.0, 5.0, 4.0, 3.0), color))
|
||||
|
||||
makeNewSprite(FixtureBase.getSpritesheet("basegame", "sprites/fixtures/tiki_torch.tga", 16, 32))
|
||||
sprite!!.setRowsAndFrames(1, 2)
|
||||
makeNewSprite(FixtureBase.getSpritesheet("basegame", "sprites/fixtures/tiki_torch.tga", 16, 32)).let {
|
||||
it.setRowsAndFrames(1,2)
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = MASS
|
||||
}
|
||||
@@ -73,7 +75,7 @@ internal class FixtureTikiTorch : FixtureBase, Luminous {
|
||||
spawnTimer -= nextDelay
|
||||
nextDelay = rng.nextFloat() * 0.25f + 0.25f
|
||||
|
||||
sprite?.delays?.set(0, rng.nextFloat() * 0.4f + 0.1f)
|
||||
(sprite as? SheetSpriteAnimation)?.delays?.set(0, rng.nextFloat() * 0.4f + 0.1f)
|
||||
}
|
||||
|
||||
spawnTimer += delta
|
||||
|
||||
@@ -83,9 +83,9 @@ class IngamePlayer : ActorHumanoid, HasAssembledSprite {
|
||||
/** To be used later by the game to rebuild the sprite.
|
||||
* Which `_rebuild` function to use is determined at the load time.
|
||||
*/
|
||||
@Transient private lateinit var rebuildfun: (item: GameItem?) -> Unit
|
||||
@Transient private lateinit var rebuildfunGlow: (item: GameItem?) -> Unit
|
||||
@Transient internal var rebuildingDiskSkimmer: DiskSkimmer? = null
|
||||
// @Transient private lateinit var rebuildfun: (item: GameItem?) -> Unit
|
||||
// @Transient private lateinit var rebuildfunGlow: (item: GameItem?) -> Unit
|
||||
// @Transient internal var rebuildingDiskSkimmer: DiskSkimmer? = null
|
||||
|
||||
/**
|
||||
* Example usage:
|
||||
@@ -97,7 +97,7 @@ class IngamePlayer : ActorHumanoid, HasAssembledSprite {
|
||||
* reassembleSprite(this.sprite, this.spriteGlow)
|
||||
* ```
|
||||
*/
|
||||
override fun reassembleSprite(sprite: SpriteAnimation?, spriteGlow: SpriteAnimation?, heldItem: GameItem?) {
|
||||
/*override fun reassembleSprite(sprite: SpriteAnimation?, spriteGlow: SpriteAnimation?, heldItem: GameItem?) {
|
||||
if (animDesc != null && sprite != null) {
|
||||
rebuildfun = { item: GameItem? -> _rebuild(animDesc!!, sprite, item) }; rebuildfun(heldItem)
|
||||
spriteHeadTexture = AssembleSheetPixmap.getMugshotFromAssetsDir(animDesc!!)
|
||||
@@ -119,9 +119,9 @@ class IngamePlayer : ActorHumanoid, HasAssembledSprite {
|
||||
}
|
||||
if (animDescGlow != null && spriteGlow != null)
|
||||
rebuildfunGlow = { item: GameItem? -> _rebuild(disk, -1026L, animDescGlow!!, spriteGlow, item) }; rebuildfunGlow(heldItem)
|
||||
}
|
||||
}*/
|
||||
|
||||
private fun _rebuild(ad: ADProperties, sprite: SpriteAnimation, item: GameItem?) {
|
||||
/*private fun _rebuild(ad: ADProperties, sprite: SpriteAnimation, item: GameItem?) {
|
||||
// TODO injecting held item/armour pictures? Would it be AssembleSheetPixmap's job?
|
||||
|
||||
val pixmap = AssembleSheetPixmap.fromAssetsDir(ad, item)
|
||||
@@ -167,15 +167,15 @@ class IngamePlayer : ActorHumanoid, HasAssembledSprite {
|
||||
sprite.delays = newAnimDelays
|
||||
sprite.nFrames = newAnimFrames
|
||||
sprite.nRows = newAnimDelays.size
|
||||
}
|
||||
}*/
|
||||
|
||||
override fun getSpriteHead(): TextureRegion? {
|
||||
/*override fun getSpriteHead(): TextureRegion? {
|
||||
return spriteHeadTexture
|
||||
}
|
||||
}*/
|
||||
|
||||
@Transient private var unequipNoSpriteUpdate = false
|
||||
|
||||
override fun equipItem(item: GameItem) {
|
||||
/*override fun equipItem(item: GameItem) {
|
||||
val oldItemID = inventory.itemEquipped[item.equipPosition]
|
||||
|
||||
unequipNoSpriteUpdate = true
|
||||
@@ -208,5 +208,5 @@ class IngamePlayer : ActorHumanoid, HasAssembledSprite {
|
||||
|
||||
// println("IngamePlayer.unequipItem")
|
||||
// printStackTrace(this)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-25.
|
||||
*/
|
||||
object PlayerBuilderCynthia {
|
||||
/*object PlayerBuilderCynthia {
|
||||
|
||||
operator fun invoke(): ActorWithBody {
|
||||
//val p: IngamePlayer = IngamePlayer(GameDate(100, 143)) // random value thrown
|
||||
@@ -44,4 +44,4 @@ object PlayerBuilderCynthia {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}*/
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.AssembledSpriteAnimation
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
@@ -27,9 +28,9 @@ object PlayerBuilderTestSubject1 {
|
||||
p.sprite!!.delays = floatArrayOf(2f, 1f/12f) // second value does nothing -- overridden by ActorHumanoid.updateSprite(float)
|
||||
p.sprite!!.setRowsAndFrames(2, 4)*/
|
||||
|
||||
p.sprite = SpriteAnimation(p)
|
||||
p.spriteGlow = SpriteAnimation(p)
|
||||
p.reassembleSprite(p.sprite, p.spriteGlow, null)
|
||||
p.animDesc?.let { p.sprite = AssembledSpriteAnimation(it, p) }
|
||||
p.animDescGlow?.let { p.spriteGlow = AssembledSpriteAnimation(it, p) }
|
||||
//p.reassembleSprite(p.sprite, p.spriteGlow, null)
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
// ingame must teleport the player to the spawn point
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.AssembledSpriteAnimation
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
@@ -28,9 +29,9 @@ object PlayerBuilderWerebeastTest {
|
||||
p.sprite!!.delays = floatArrayOf(2f, 1f/12f) // second value does nothing -- overridden by ActorHumanoid.updateSprite(float)
|
||||
p.sprite!!.setRowsAndFrames(2, 4)*/
|
||||
|
||||
p.sprite = SpriteAnimation(p)
|
||||
p.spriteGlow = SpriteAnimation(p)
|
||||
p.reassembleSprite(p.sprite, p.spriteGlow, null)
|
||||
p.animDesc?.let { p.sprite = AssembledSpriteAnimation(it, p) }
|
||||
p.animDescGlow?.let { p.spriteGlow = AssembledSpriteAnimation(it, p) }
|
||||
//p.reassembleSprite(p.sprite, p.spriteGlow, null)
|
||||
p.setHitboxDimension(22, p.actorValue.getAsInt(AVKey.BASEHEIGHT)!!, 30, 0)
|
||||
|
||||
p.setPosition(3.0 * TILE_SIZE, 3.0 * TILE_SIZE)
|
||||
|
||||
Reference in New Issue
Block a user