/
legacy.go
57 lines (46 loc) · 1.48 KB
/
legacy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package mouse
import "github.com/oakmound/oak/collision"
// There is no legacy_test.go because these functions are duplicate of functions
// in collision/legacy.go
// There's a default collision tree you can access via collision.func
// as opposed to tree.func
var (
DefTree *collision.Tree
)
func init() {
DefTree, _ = collision.NewTree()
}
// Clear resets the default collision tree
func Clear() {
DefTree.Clear()
}
// Add adds a set of spaces to the rtree
func Add(sps ...*collision.Space) {
DefTree.Add(sps...)
}
// Remove removes a space from the rtree
func Remove(sps ...*collision.Space) {
DefTree.Remove(sps...)
}
// UpdateSpace resets a space's location to a given
// rtreego.Rect.
// This is not an operation on a space because
// a space can exist in multiple rtrees.
func UpdateSpace(x, y, w, h float64, s *collision.Space) error {
return DefTree.UpdateSpace(x, y, w, h, s)
}
// ShiftSpace adds x and y to a space and updates its position
// in the collision rtree that should not be a package global
func ShiftSpace(x, y float64, s *collision.Space) error {
return DefTree.ShiftSpace(x, y, s)
}
// Hits returns the set of spaces which are colliding
// with the passed in space.
func Hits(sp *collision.Space) []*collision.Space {
return DefTree.Hits(sp)
}
// HitLabel acts like hits, but reutrns the first space within hits
// that matches one of the input labels
func HitLabel(sp *collision.Space, labels ...collision.Label) *collision.Space {
return DefTree.HitLabel(sp, labels...)
}