mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
on-the-fly sprite assembly WIP
This commit is contained in:
@@ -3,6 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.spriteanimation.HasAssembledSprite
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
@@ -21,6 +22,11 @@ import java.util.*
|
||||
* Humanoid actor class to provide same controlling function (such as work, jump)
|
||||
* Also applies unreal air friction for movement control
|
||||
*
|
||||
* For some actors that "HasAssembledSprite", sprite rows must be in this specific order:
|
||||
* 1. Idle
|
||||
* 2. Walk
|
||||
* ...
|
||||
*
|
||||
* Created by minjaesong on 2016-10-24.
|
||||
*/
|
||||
open class ActorHumanoid(
|
||||
@@ -610,8 +616,11 @@ open class ActorHumanoid(
|
||||
|
||||
// set anim frame delay
|
||||
// 4f of the divider is a magic number, empirically decided
|
||||
sprite?.delays?.set(SPRITE_ROW_WALK, scale.sqrt().toFloat() / (4f * (controllerMoveDelta?.x ?: 0.0001).abs().toFloat())) // FIXME empirical value
|
||||
spriteGlow?.delays?.set(SPRITE_ROW_WALK, scale.sqrt().toFloat() / (4f * (controllerMoveDelta?.x ?: 0.0001).abs().toFloat())) // FIXME empirical value
|
||||
if (this is HasAssembledSprite) {
|
||||
sprite?.delays?.set(SPRITE_ROW_WALK, scale.sqrt().toFloat() / (4f * (controllerMoveDelta?.x ?: 0.0001).abs().toFloat())) // FIXME empirical value
|
||||
spriteGlow?.delays?.set(SPRITE_ROW_WALK, scale.sqrt().toFloat() / (4f * (controllerMoveDelta?.x ?: 0.0001).abs().toFloat())) // FIXME empirical value
|
||||
|
||||
}
|
||||
|
||||
// flipping the sprite
|
||||
if (walkHeading == LEFT) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import net.torvald.spriteanimation.HasAssembledSprite
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
|
||||
|
||||
@@ -11,7 +12,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
*/
|
||||
|
||||
class IngamePlayer(born: time_t) : ActorHumanoid(born) {
|
||||
class IngamePlayer(override var animDesc: FileHandle, born: time_t) : ActorHumanoid(born), HasAssembledSprite {
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
@@ -13,7 +14,7 @@ object PlayerBuilder {
|
||||
operator fun invoke(): Actor {
|
||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||
|
||||
val p: Actor = IngamePlayer(world.time.TIME_T)
|
||||
val p: Actor = IngamePlayer(Gdx.files.internal("lol"), world.time.TIME_T)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
@@ -14,7 +15,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
object PlayerBuilderSigrid {
|
||||
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p = IngamePlayer(-9223372036854775807L) // XD
|
||||
val p = IngamePlayer(Gdx.files.internal("lol"), - 9223372036854775807L) // XD
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-02-10.
|
||||
*/
|
||||
object PlayerBuilderTestSubject1 {
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p: IngamePlayer = IngamePlayer(-589141658L) // random value thrown
|
||||
val p: IngamePlayer = IngamePlayer(ModMgr.getGdxFile("basegame", "sprites/test_sprite.properties"), -589141658L) // random value thrown
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
|
||||
@@ -20,10 +20,12 @@ object PlayerBuilderTestSubject1 {
|
||||
p.actorValue[AVKey.NAME] = "Test Subject 1"
|
||||
|
||||
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/npc_template_anim_prototype.tga"), 48, 52))
|
||||
/*p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/npc_template_anim_prototype.tga"), 48, 52))
|
||||
p.sprite!!.delays = floatArrayOf(2f, 1f/12f) // second value does nothing -- overridden by ActorHumanoid.updateSprite(float)
|
||||
p.sprite!!.setRowsAndFrames(2, 4)
|
||||
p.sprite!!.setRowsAndFrames(2, 4)*/
|
||||
|
||||
p.sprite = SpriteAnimation(p)
|
||||
p.reassembleSprite(p.sprite!!)
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
p.setPosition(3.0 * FeaturesDrawer.TILE_SIZE, 3.0 * FeaturesDrawer.TILE_SIZE)
|
||||
|
||||
@@ -4,10 +4,10 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
|
||||
/**
|
||||
@@ -39,8 +39,7 @@ class UIItemInventoryEquippedView(
|
||||
|
||||
val spriteViewBackCol: Color; get() = Color(0x404040_88.toInt())//Color(0xd4d4d4_ff.toInt())
|
||||
|
||||
private val itemGrid = Array<UIItemInventoryCellBase>(
|
||||
2 * 5, {
|
||||
private val itemGrid = Array<UIItemInventoryCellBase>(2 * 5) {
|
||||
UIItemInventoryElemSimple(
|
||||
parentUI = parentUI,
|
||||
posX = this.posX + (UIItemInventoryElemSimple.height + listGap) * ((it + 4) % 2),
|
||||
@@ -55,7 +54,6 @@ class UIItemInventoryEquippedView(
|
||||
drawBackOnNull = true
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
|
||||
Reference in New Issue
Block a user