smoothDelta is now come from Gdx's LwjglGraphics instead of AppLoader

This commit is contained in:
minjaesong
2019-01-22 13:16:21 +09:00
parent a59a1d5c2f
commit 07373e13d2
13 changed files with 27 additions and 127 deletions

View File

@@ -425,7 +425,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
}
}
private var countdownToDeltaReset = 15 // number of frames
private var updateAkku = 0.0
override fun render(delta: Float) {
@@ -447,19 +446,10 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
gameFullyLoaded = true
}
if (countdownToDeltaReset >= 0) {
if (countdownToDeltaReset == 0) {
AppLoader.resetDeltaSmoothingHistory()
}
countdownToDeltaReset -= 1
}
// ASYNCHRONOUS UPDATE AND RENDER //
/** UPDATE CODE GOES HERE */
val dt = AppLoader.getSmoothDelta()
val dt = Gdx.graphics.deltaTime
updateAkku += dt
var i = 0L
@@ -477,10 +467,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
AppLoader.debugTimers["Ingame.render-Light"] =
(AppLoader.debugTimers["Ingame.render"] as Long) - ((AppLoader.debugTimers["Renderer.LightTotal"] as? Long) ?: 0)
AppLoader.debugTimers["Gdx.deltaRaw"] = Gdx.graphics.rawDeltaTime.times(1_000_000_000).toLong()
AppLoader.debugTimers["Gdx.deltaSmt"] = Gdx.graphics.deltaTime.times(1_000_000_000).toLong()
}
protected fun updateGame(delta: Float) {

View File

@@ -211,7 +211,7 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
actor.avStrength / 1000.0
else
1.0 // TODO variable: scale, strength
val swingDmgToFrameDmg = AppLoader.getSmoothDelta().toFloat().toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
val swingDmgToFrameDmg = AppLoader.UPDATE_RATE.toFloat().toDouble() / actor.actorValue.getAsDouble(AVKey.ACTION_INTERVAL)!!
// damage the item
newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat()

View File

@@ -23,7 +23,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision
/** Will NOT actually delete from the CircularArray */
@Volatile var flagDespawn = false
override fun run() = update(AppLoader.getSmoothDelta().toFloat())
override fun run() = update(AppLoader.UPDATE_RATE.toFloat())
var isNoSubjectToGrav = false
var dragCoefficient = 3.0

View File

@@ -28,7 +28,7 @@ interface Pocketed {
}
inventory.itemEquipped[item.equipPosition] = null
item.effectOnUnequip(AppLoader.getSmoothDelta().toFloat())
item.effectOnUnequip(AppLoader.UPDATE_RATE.toFloat())
}
// no need for equipSlot(Int)
@@ -50,7 +50,7 @@ interface Pocketed {
if (item.equipPosition >= 0) {
inventory.itemEquipped[item.equipPosition] = item
item.effectWhenEquipped(AppLoader.getSmoothDelta().toFloat())
item.effectWhenEquipped(AppLoader.UPDATE_RATE.toFloat())
}
// else do nothing
}
@@ -69,13 +69,13 @@ interface Pocketed {
fun consumePrimary(item: GameItem) {
if (item.startPrimaryUse(AppLoader.getSmoothDelta().toFloat())) {
if (item.startPrimaryUse(AppLoader.UPDATE_RATE.toFloat())) {
inventory.consumeItem(this as Actor, item) // consume on successful
}
}
fun consumeSecondary(item: GameItem) {
if (item.startSecondaryUse(AppLoader.getSmoothDelta().toFloat()))
if (item.startSecondaryUse(AppLoader.UPDATE_RATE.toFloat()))
inventory.consumeItem(this as Actor, item) // consume on successful
}
}

View File

@@ -10,13 +10,13 @@ class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Runnable {
override fun run() {
for (i in startIndex..endIndex) {
val it = Terrarum.ingame!!.actorContainer[i]
it.update(AppLoader.getSmoothDelta().toFloat())
it.update(AppLoader.UPDATE_RATE.toFloat())
if (it is Pocketed) {
it.inventory.forEach { inventoryEntry ->
inventoryEntry.item.effectWhileInPocket(AppLoader.getSmoothDelta().toFloat())
inventoryEntry.item.effectWhileInPocket(AppLoader.UPDATE_RATE.toFloat())
if (it.equipped(inventoryEntry.item)) {
inventoryEntry.item.effectWhenEquipped(AppLoader.getSmoothDelta().toFloat())
inventoryEntry.item.effectWhenEquipped(AppLoader.UPDATE_RATE.toFloat())
}
}
}