func makeDot(v mgl32.Vec2, a float32, i int, clr mgl32.Vec4) mesh.Mesh { m := mesh.Mesh{ Nmbr: mesh.Number(i), Dpth: 0.5, Vrts: []mgl32.Vec2{ {-dotx, 0}, // 0 {0, -doty}, // 1 {dotx, 0}, // 2 {0, doty}, // 3 }, Clrs: []mgl32.Vec4{ clr, }, Trngls: []mesh.Triangle{ { Vnd: mesh.Nd{0, 1, 2}, Flvr: mesh.CONVEX, }, { Vnd: mesh.Nd{2, 3, 0}, Flvr: mesh.CONVEX, }, }, } m.Transform(mgl32.HomogRotate2D(a)) // rotate by a m.Transform(mgl32.Translate2D(v.Elem())) // translate by v return m }
func (ai *AI) movePathed(position mgl32.Vec2) { minDistance2 := square(float32(ai.Me.Size) + costMapReduction*1.3) if dist2(ai.Me.Position, position) < minDistance2 { ai.addStatusMessage("Objective is within minimum distance. Moving directly to objective.") ai.Path = []mgl32.Vec2{ai.Me.Position, position} ai.g.SetTargetPos(position.X(), position.Y()) return } // meNode := ai.Map.GetNode(gameToCostMap(ai.Me.Position.Elem())) // positionNode := ai.Map.GetNode(gameToCostMap(position.Elem())) // path, cost, nodes := search.AStar(meNode, positionNode, ai.Map, nil, nil) // if path == nil { // ai.addStatusMessage("Failed to find path. Trying undirected.") // ai.movePathedUndirected(position) // return // } // ai.addStatusMessage(fmt.Sprintf("A*: path cost: %.2f / nodes expanded: %d", cost, nodes)) positionNode := ai.Map.GetNode(gameToCostMap(position.Elem())) path, cost := ai.DijkstraMap.To(positionNode) if path == nil { ai.addStatusMessage("movePathed: Failed to find path. Moving directly to objective.") ai.Path = []mgl32.Vec2{ai.Me.Position, position} ai.g.SetTargetPos(position.X(), position.Y()) return } ai.addStatusMessage(fmt.Sprintf("movePathed: path cost: %.2f", cost)) ai.moveAlongPath(position, path) }