need help with missle code please

BlitzMax Forums/BlitzMax Programming/need help with missle code please

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

i've typed up some rough code as a place to start, and it
works and looks fairly decent, but not as well as i'd like.

1. how would i get the missle to go in a straight line even on and angle, instead of doing the over 1, up 1 type thing.

2. how do i get a trail to follow the missle, regardless of
the angle. as is right now it follows it from then center of origin, and when the missle rotates the trail doesn't always line up.
also i'd like the trail to start at the end of the missle, and not the middle.

any help would be appreciated.



'move missle to target
    If missleon = 1
        'create the smoke and fire trail
        Local r=Rand(0,100)
        If  r>95
            TParticles.CreateParticle(mx#+Sin(mx#),my#+Cos(my#),500,"smoke",0.01,1)
            TParticles.CreateParticle(mx#+Sin(mx#),my#+Cos(my#),10,"fire",0.1,1)
        EndIf
        
        'move
        If mx# < tmx# then mx#:+mxspeed#
        If mx# > tmx# Then mx#:-mxspeed#

        If my# < tmx# then my#:+myspeed#
        If my# > tmx# Then my#:-myspeed#

        If mx# = tmx# And my# = tmy# Then missleon = 0

        'get the angle between missle and target 
        'to point the missle at the target
        misslerot# = Angle360b#(mx#,my#,tmx#,tmy#)
    EndIf

Function Angle360b#(x1,y1,x2,y2)
    'Returns a 360 degree angle between 2 points, 0..359 degrees
    'By Snarkbait, 9 Mar 2008
    Return (ATan2(y2-y1,x2-x1)+450) Mod 360
End Function