Answered by:
Help!! I Cant make the missile turn acording to the Speed!
Question

DXG967
in This program I am trying to make something having to do with artillery wars but, as the missile comes out of the barrel I cant make it always make it point the direction that is going (eg; pointing down when its falling and pointing flat when its flying strait) could anyone reply with a sorce code that would show me how to do that?
 Edited by Zock77Editor Thursday, April 26, 2012 3:16 AM
Answers

We need to calculate the velocity vector and convert this to an angle to rotate the arrow. The rotation is in degrees clockwise with 0 in the X direction. This should do the trick. First get the velocities, then get the angle, then rotate.
Nice game in progress.
'Rotate the arrow with direction velX = Vh2 velY = Vv2 + Timenow2 * Gravity If (velX = 0) Then angleArrow = Math.Pi/2 Else angleArrow = Math.ArcTan(velY/velX) EndIf If (velX < 0) Then angleArrow = angleArrow+Math.Pi EndIf Shapes.Rotate(Ball2,angleArrow*180/Math.Pi)
 Marked as answer by Zock77Editor Thursday, April 26, 2012 7:03 PM
All replies

How about this. JWZ9640
maybe this program is not so good. but works.
( If textwindow use, graphics.keydown doesnot work. So I used shape message.)
* Comments are added. JWZ9640 Edited by NaochanONEditor Thursday, April 26, 2012 1:46 PM add comments

We need to calculate the velocity vector and convert this to an angle to rotate the arrow. The rotation is in degrees clockwise with 0 in the X direction. This should do the trick. First get the velocities, then get the angle, then rotate.
Nice game in progress.
'Rotate the arrow with direction velX = Vh2 velY = Vv2 + Timenow2 * Gravity If (velX = 0) Then angleArrow = Math.Pi/2 Else angleArrow = Math.ArcTan(velY/velX) EndIf If (velX < 0) Then angleArrow = angleArrow+Math.Pi EndIf Shapes.Rotate(Ball2,angleArrow*180/Math.Pi)
 Marked as answer by Zock77Editor Thursday, April 26, 2012 7:03 PM

