Making homing lazers with faiding tails

BlitzMax Forums/BlitzMax Beginners Area/Making homing lazers with faiding tails

I'm at a loss, I would likke to make homing lazers with fading tails like the game Rayhound. I don't want to use particles. Has anyone gotten a good system for having fading trails on shots?

http://www.the2bears.com/?p=587

Contains bullet trail example

That's not the solution I need. These lazers are drawn to some buffer I think probably primatives and then they are progressevly faded into the background. It could easly be done with Game Maker's surfaces if anyone is familiar with those.... I just don't know how to do it in Blitzmax because it doesn't seem to offer any fast way of storing dynamic images. If it had another buffer you would simply make the buffer transparent and draw the trail segment each time and then draw a whole semi transparent rectangle over the ectra buffer so it fades over time.

Not sure why you can't start with that code but never mind. You might check IndiePath's RTT code or Diablo's HighGFX.

Here is some simple code I have put together :

Global TrailImage:TImage = LoadImage("bluspark.bmp",MASKEDIMAGE)
MidHandleImage(TrailImage)

Type TTrail
	Field X:Int,Y:Int
	Field Life:Int = 2000
	Field StartTime:Int = MilliSecs()
	
	Function Create:TTrail(X:Int,Y:Int)
		Local T:TTrail = New TTrail
		T.X = X
		T.Y = Y
		Return T
	End Function
	
	Method Update()
		Local Alpha:Float = .5-((.5/(Life/2))*(MilliSecs()-StartTime))
		If Alpha < 0 Then Alpha = 0
		SetBlend LightBlend
		SetAlpha Alpha
		SetColor 255,255,255
		'DrawOval X-5,Y-5,10,10
		SetScale 0.3,0.3
		DrawImage(TrailImage,x,y)
		SetColor 255,255,255
		SetAlpha 1.0
		SetBlend AlphaBLend
		SetScale 1.0,1.0
	End Method
	
	Method isDead:Byte()
		If MilliSecs()-StartTime > Life Then Return True
		Return False
	End Method
		
End Type

Type TRocket
	Field X:Float
	Field Y:Float
	Field EX:Int
	Field EY:Int
	Field Rate:Int = 3
	Field last:Int = 0
	
	Field TrailList:TList = New TList
	
	Function Create:TRocket(X:Int,Y:Int,EX:Int,EY:Int)
		Local R:TRocket = New TRocket
		R.X = X
		R.Y = Y
		R.EX = EX
		R.EY = EY
		Return R
	End Function
	
	Method Update()
		Local Angle:Float = (ATan2(Y-EY,x-ex)+360) Mod 360
		Local SpeedX:Float = -Cos(Angle)*2.0
		Local SpeedY:Float = -Sin(Angle)*2.0
		X:+SpeedX
		Y:+SpeedY
		'Print Dist2d(x,y,ex,ey)
		If Dist2d(x,y,ex,ey) > 4 And MilliSecs()-last > rate Then
			TrailList.Addlast(TTrail.Create(X,Y))
			last = MilliSecs()
		EndIf
		
		For Local T:TTrail = EachIn TrailList
			T.Update()
			If T.isDead() = True Then 
				TrailList.Remove(T)
			EndIf
		Next
	End Method
	
	Method isDead:Byte()
		If Dist2d(x,y,ex,ey) <= 4 And TrailList.Count() = 0 Then
			 Return True
		EndIf
		Return False
	End Method
	

End Type

Function Dist2D:Float(x1#,y1#,x2#,y2#)
	Return Sqr(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
End Function


Graphics 800,600,0,-1

Local RList:TList = New TList

Local StartX:Int = 0
Local StartY:Int = 0
Local EndX:Int = 0
Local EndY:Int = 0

While Not KeyHit(Key_Escape)
	Cls
		'If MouseHit(1) Then 
		'	StartX = MouseX()
		'	StartY = MouseY()
		'EndIf
		
		'If MouseHit(2) Then 
		'	EndX = MouseX()
		'	EndY = MouseY()
		If RList.Count() < 10 Then 
			RList.Addlast(TRocket.Create(Rnd(800),Rnd(600),Rnd(800),Rnd(600)))
		EndIf
		
		For Local R:TRocket = EachIn RList
			R.Update()
			If R.isDead() = True Then RList.Remove(R)
		Next
		
		DrawText "Start X : " + StartX + " Start Y: " + StartY,20,20
		DrawText "End X : " + EndX + " End Y: " + EndY,20,40


		
	Flip
End While


The magic word in this case might be 'LIGHTBLEND'.

Thanks for your time, I got something similar working. :)