1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-28 22:26:30 -04:00
OpenDiablo2/d2common/d2fileformats/d2cof/helpers.go

28 lines
451 B
Go
Raw Normal View History

2021-02-25 03:30:59 -05:00
package d2cof
2021-02-25 14:21:44 -05:00
// FPS returns FPS value basing on cof's speed
func (c *COF) FPS() float64 {
2021-02-25 03:30:59 -05:00
const (
baseFPS = 25
speedDivisor = 256
)
fps := baseFPS * (float64(c.Speed) / speedDivisor)
if fps == 0 {
fps = baseFPS
}
return fps
}
2021-02-25 03:33:47 -05:00
// Duration returns animation's duration
func (c *COF) Duration() float64 {
const (
milliseconds = 1000
)
2021-02-25 14:25:39 -05:00
frameDelay := milliseconds / c.FPS()
2021-02-25 03:33:47 -05:00
return float64(c.FramesPerDirection) * frameDelay
}