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

Fixed crash on 0 animation speed entities. (#164)

This commit is contained in:
Tim Sarbin 2019-11-13 15:08:09 -05:00 committed by GitHub
parent 78a70c2d2b
commit da9b86c679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,11 +137,13 @@ func (v *AnimatedEntity) LoadLayer(layer string, fileProvider d2interface.FilePr
// Render draws this animated entity onto the target
func (v *AnimatedEntity) Render(target *ebiten.Image, offsetX, offsetY int) {
for v.lastFrameTime.Add(time.Millisecond * time.Duration(v.animationSpeed)).Before(time.Now()) {
v.lastFrameTime = v.lastFrameTime.Add(time.Millisecond * time.Duration(v.animationSpeed))
v.currentFrame++
if v.currentFrame >= v.framesToAnimate {
v.currentFrame = 0
if v.animationSpeed > 0 {
for v.lastFrameTime.Add(time.Millisecond * time.Duration(v.animationSpeed)).Before(time.Now()) {
v.lastFrameTime = v.lastFrameTime.Add(time.Millisecond * time.Duration(v.animationSpeed))
v.currentFrame++
if v.currentFrame >= v.framesToAnimate {
v.currentFrame = 0
}
}
}
for idx := 0; idx < v.Cof.NumberOfLayers; idx++ {