1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-10-31 16:27:18 -04:00
OpenDiablo2/d2render/animated_entity_test.go
nicholas-eden b5db51800c Setup NPCs to follow paths (#243)
Change location to contain canonical location, add field to get rounded location for tile rendering.
If NPC has path, loop through path.
2019-12-06 09:44:51 -05:00

55 lines
1.1 KiB
Go

package d2render
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestAngleToDirection_16Directions(t *testing.T) {
numberOfDirections := 16
angle := 45.0
for i := 0; i < numberOfDirections; i++ {
assert.Equal(t, i, angleToDirection(angle, numberOfDirections))
angle += 22.5
}
angle = 50.0
for i := 0; i < numberOfDirections; i++ {
assert.Equal(t, i, angleToDirection(angle, numberOfDirections))
angle += 22.5
}
angle = 40.0
for i := 0; i < numberOfDirections; i++ {
assert.Equal(t, i, angleToDirection(angle, numberOfDirections))
angle += 22.5
}
}
func TestAngleToDirection_8Directions(t *testing.T) {
numberOfDirections := 8
angle := 45.0
for i := 0; i < numberOfDirections; i++ {
assert.Equal(t, i, angleToDirection(angle, numberOfDirections))
angle += 45
}
angle = 50.0
for i := 0; i < numberOfDirections; i++ {
assert.Equal(t, i, angleToDirection(angle, numberOfDirections))
angle += 45
}
angle = 40.0
for i := 0; i < numberOfDirections; i++ {
assert.Equal(t, i, angleToDirection(angle, numberOfDirections))
angle += 45
}
}