varying amplitude for throwing sound

This commit is contained in:
minjaesong
2024-07-14 02:06:58 +09:00
parent 96f858fa51
commit 23d99c0c86
3 changed files with 28 additions and 9 deletions

View File

@@ -913,7 +913,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
// process actor addition requests
val addCueCpy = actorAdditionQueue.toList()
addCueCpy.forEach { forceAddActor(it.first, it.second) }
addCueCpy.forEach {
forceAddActor(it.first, it.second)
it.third(it.first)
}
actorAdditionQueue.removeAll(addCueCpy)
// determine whether the inactive actor should be activated
wakeDormantActors()
@@ -923,7 +926,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
killOrKnockdownActors()
// process actor removal requests
val remCueCpy = actorRemovalQueue.toList()
remCueCpy.forEach { forceRemoveActor(it.first, it.second) }
remCueCpy.forEach {
forceRemoveActor(it.first, it.second)
it.third(it.first)
}
actorRemovalQueue.removeAll(remCueCpy)
// update particles
particlesContainer.toList().forEach { if (!it.flagDespawn) particlesActive++; it.update(delta) }

View File

@@ -12,6 +12,7 @@ import net.torvald.terrarum.gameactors.Lightbox
import net.torvald.terrarum.gameactors.PhysProperties
import net.torvald.terrarum.modulebasegame.ExplosionManager
import kotlin.math.log10
import kotlin.math.pow
/**
* Created by minjaesong on 2024-07-12.
@@ -20,10 +21,11 @@ open class ActorLobbed(throwPitch: Float) : ActorWithBody() {
protected constructor() : this(1f)
@Transient private val pitch = throwPitch.coerceIn(0.5f, 2f)
@Transient private val whooshSound = MusicContainer(
"throw_low_short", ModMgr.getFile("basegame", "audio/effects/throwing/throw_low_short.wav"),
toRAM = true,
samplingRateOverride = 48000f * throwPitch.coerceIn(0.5f, 2f)
samplingRateOverride = 48000f * pitch
)
init {
@@ -38,7 +40,8 @@ open class ActorLobbed(throwPitch: Float) : ActorWithBody() {
super.updateImpl(delta)
if (!soundFired) {
soundFired = true
startAudio(whooshSound, 1.0)
val amp = 1.65 * (pitch - 0.495)
startAudio(whooshSound, amp)
}
}
}