mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-17 18:06:03 -05:00
28 lines
472 B
Go
28 lines
472 B
Go
package d2cof
|
|
|
|
// SpeedToFPS returns FPS value basing on cof's speed
|
|
func (c *COF) SpeedToFPS() float64 {
|
|
const (
|
|
baseFPS = 25
|
|
speedDivisor = 256
|
|
)
|
|
|
|
fps := baseFPS * (float64(c.Speed) / speedDivisor)
|
|
if fps == 0 {
|
|
fps = baseFPS
|
|
}
|
|
|
|
return fps
|
|
}
|
|
|
|
// Duration returns animation's duration
|
|
func (c *COF) Duration() float64 {
|
|
const (
|
|
milliseconds = 1000
|
|
)
|
|
|
|
frameDelay := milliseconds / c.SpeedToFPS()
|
|
|
|
return float64(c.FramesPerDirection) * frameDelay
|
|
}
|