mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 14:34:04 +09:00
newfontsystem branch init commit
Former-commit-id: 5f03cdbec6058f90ef1354db5ee1c6dac9755feb Former-commit-id: f132b6c4e1a51146fb7522686e24008640e88c45
This commit is contained in:
@@ -79,6 +79,9 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
@Transient internal const val WALK_ACCEL_BASE: Double = 0.67
|
||||
|
||||
@Transient const val BASE_HEIGHT = 40
|
||||
|
||||
@Transient const val SPRITE_ROW_IDLE = 0
|
||||
@Transient const val SPRITE_ROW_WALK = 1
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -499,12 +502,19 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
fun Float.abs() = FastMath.abs(this)
|
||||
|
||||
private fun updateSprite(delta: Int) {
|
||||
sprite!!.update(delta)
|
||||
if (spriteGlow != null) {
|
||||
spriteGlow!!.update(delta)
|
||||
}
|
||||
if (sprite != null) sprite!!.update(delta)
|
||||
if (spriteGlow != null) spriteGlow!!.update(delta)
|
||||
|
||||
println("$this\tsprite current frame: ${sprite!!.currentFrame}")
|
||||
|
||||
if (grounded) {
|
||||
// set anim row
|
||||
if (moveDelta.x != 0.0) {
|
||||
if (sprite != null) sprite!!.switchRow(SPRITE_ROW_WALK)
|
||||
if (spriteGlow != null) spriteGlow!!.switchRow(SPRITE_ROW_WALK)
|
||||
}
|
||||
|
||||
// flipping the sprite
|
||||
if (walkHeading == LEFT) {
|
||||
sprite!!.flip(true, false)
|
||||
if (spriteGlow != null) {
|
||||
@@ -518,5 +528,9 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sprite != null) sprite!!.switchRow(SPRITE_ROW_IDLE)
|
||||
if (spriteGlow != null) spriteGlow!!.switchRow(SPRITE_ROW_IDLE)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,6 +342,9 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
||||
|
||||
if (!assertPrinted) assertInit()
|
||||
|
||||
if (sprite != null) sprite!!.update(delta)
|
||||
if (spriteGlow != null) spriteGlow!!.update(delta)
|
||||
|
||||
// make NoClip work for player
|
||||
if (this is Player) {
|
||||
isNoSubjectToGrav = isPlayerNoClip
|
||||
@@ -569,7 +572,7 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
||||
externalForce.x *= -elasticity
|
||||
if (this is Controllable) walkX *= -elasticity
|
||||
|
||||
println("$this\t${externalForce.x}")
|
||||
//println("$this\t${externalForce.x}")
|
||||
}
|
||||
|
||||
private fun hitAndReflectY() {
|
||||
@@ -1143,14 +1146,6 @@ open class ActorWithSprite(renderOrder: ActorOrder, val immobileBody: Boolean =
|
||||
}
|
||||
}
|
||||
|
||||
open fun updateGlowSprite(gc: GameContainer, delta: Int) {
|
||||
if (spriteGlow != null) spriteGlow!!.update(delta)
|
||||
}
|
||||
|
||||
open fun updateBodySprite(gc: GameContainer, delta: Int) {
|
||||
if (sprite != null) sprite!!.update(delta)
|
||||
}
|
||||
|
||||
private fun clampW(x: Double): Double =
|
||||
if (x < TILE_SIZE + nextHitbox.width / 2) {
|
||||
TILE_SIZE + nextHitbox.width / 2
|
||||
|
||||
@@ -26,7 +26,7 @@ class FixtureTikiTorch : FixtureBase(), Luminous {
|
||||
lightBoxList.add(Hitbox(3.0, 0.0, 4.0, 3.0))
|
||||
|
||||
makeNewSprite(10, 27, "assets/graphics/sprites/fixtures/tiki_torch.tga")
|
||||
sprite!!.setDelay(200)
|
||||
sprite!!.delay = 200
|
||||
sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 1.0
|
||||
|
||||
@@ -23,7 +23,7 @@ object PlayerBuilderCynthia {
|
||||
|
||||
|
||||
p.makeNewSprite(26, 42, "assets/graphics/sprites/test_player_2.tga")
|
||||
p.sprite!!.setDelay(200)
|
||||
p.sprite!!.delay = 200
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 9, 0)
|
||||
|
||||
@@ -27,11 +27,11 @@ object PlayerBuilderSigrid {
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
p.makeNewSprite(28, 51, "assets/graphics/sprites/test_player.tga")
|
||||
p.sprite!!.setDelay(200)
|
||||
p.sprite!!.delay = 200
|
||||
p.sprite!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.makeNewSpriteGlow(28, 51, "assets/graphics/sprites/test_player_glow.tga")
|
||||
p.spriteGlow!!.setDelay(200)
|
||||
p.spriteGlow!!.delay = 200
|
||||
p.spriteGlow!!.setRowsAndFrames(1, 1)
|
||||
|
||||
p.actorValue = ActorValue()
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameactors.ai.LuaAIWrapper
|
||||
import net.torvald.terrarum.mapdrawer.FeaturesDrawer
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-02-10.
|
||||
*/
|
||||
object PlayerBuilderTestSubject1 {
|
||||
operator fun invoke(): Player {
|
||||
val p: Player = Player(GameDate(100, 143)) // random value thrown
|
||||
InjectCreatureRaw(p.actorValue, "CreatureHuman.json")
|
||||
|
||||
|
||||
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
|
||||
p.actorValue[AVKey.NAME] = "Test Subject 1"
|
||||
|
||||
|
||||
p.makeNewSprite(48, 52, "assets/graphics/sprites/npc_template_anim_prototype.tga")
|
||||
p.sprite!!.delay = 200
|
||||
p.sprite!!.setRowsAndFrames(2, 4)
|
||||
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
p.setPosition(4096.0 * FeaturesDrawer.TILE_SIZE, 300.0 * FeaturesDrawer.TILE_SIZE)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return p
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,4 @@ class TapestryObject(val image: Image, val artName: String, val artAuthor: Strin
|
||||
override fun drawBody(g: Graphics) {
|
||||
super.drawBody(g)
|
||||
}
|
||||
|
||||
override fun updateBodySprite(gc: GameContainer, delta: Int) {
|
||||
super.updateBodySprite(gc, delta)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user