示例#1
0
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)
			}
		}
	}
}
示例#2
0
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)
}
示例#3
0
文件: game.go 项目: overmesgit/game
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)
}