func (g *Game) enemyCollisionWithShell(unitsMap map[int]*Unit, unitsTree *kdtree.T, radius float32) { for _, unit := range unitsMap { if unit.Type == Enemy { nearestNodes := unitsTree.InRange(kdtree.Point{float64(unit.X), float64(unit.Y)}, float64(radius), nil) if len(nearestNodes) > 1 { collideWithShell(nearestNodes, unit, float32(g.Step)/1000) } } } }
func insertUnitToKdTree(tree *kdtree.T, unit Movable) *kdtree.T { unitT := new(kdtree.T) unitT.Point = kdtree.Point{float64(unit.GetX()), float64(unit.GetY())} unitT.Data = unit return tree.Insert(unitT) }
func insertUnitToKdTree(tree *kdtree.T, unit *Unit) *kdtree.T { unitT := new(kdtree.T) unitT.Point = kdtree.Point{float64(unit.X), float64(unit.Y)} unitT.Data = unit return tree.Insert(unitT) }