So I have my aliens following beziers but since the bezier's points are not evenly distributed the aliens cant seem to maintain the right speed.
A friend of mine who knows visual basic told me to find the angle that points towards the next point in the bezier and have the alien fly towards the next point at one pixel per update.
I asked him "how do I find the angle?"
he gives me this VB Function (which I cant use in BMAX)
Then he says:
could anyone please explain this to me?
First, how can I find the angle in blitzmax? How can I make the alien find the angle that directs it towards the next point? Then how do I get it to follow that point and make sure it goes the same speed?
A friend of mine who knows visual basic told me to find the angle that points towards the next point in the bezier and have the alien fly towards the next point at one pixel per update.
I asked him "how do I find the angle?"
he gives me this VB Function (which I cant use in BMAX)
Public Function getAngle(ByVal x1 As Single, ByVal y1 As Single, ByVal x2 As Single, ByVal y2 As Single) As Single On Error Resume Next Dim xLength As Single Dim yLength As Single xLength = x1 - x2: yLength = y1 - y2 'look for stupid stuff If xLength = 0 Then If yLength > 0 Then getAngle = 0: Exit Function If yLength < 0 Then getAngle = 180: Exit Function If yLength = 0 Then Exit Function End If If yLength = 0 Then If xLength < 0 Then getAngle = 90: Exit Function If xLength > 0 Then getAngle = 270: Exit Function End If getAngle = Atn(yLength / xLength) getAngle = getAngle * DEG If xLength < 0 Then getAngle = getAngle + 90 ElseIf xLength > 0 Then getAngle = getAngle + 270 End If End Function
Then he says:
x = x + cos(theta) * x - sin(theta) * distance y = y + cos(theta) * y + sin(theta) * distance
could anyone please explain this to me?
First, how can I find the angle in blitzmax? How can I make the alien find the angle that directs it towards the next point? Then how do I get it to follow that point and make sure it goes the same speed?