1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-16 12:35:22 +00:00
OpenDiablo2/d2common/d2fileformats/d2cof/helpers.go

28 lines
451 B
Go
Raw Normal View History

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