Trails...

Blitz3D Forums/Blitz3D Beginners Area/Trails...

Hey i'm trying to make a trail effect in 2d... can anyone give me an example? i create a rectangle image and then place a small oval image behind it, trying to figure out how to get it to avoid the Clear screen, its a clean stiff image, no trail effect at the moment...

what do you mean by "Trail"?

1. Place every trail where you like
2. Make them to follow your image
3. Remove them after a short delay

The easiest way to add a "follow effect" or a "remove effect" can be achieved with Sprite Candy library in 2D or by using Mesh Factory library in 3D (3D trails)

For better results use random positions and/or removing times

hmm, can you give me some basic code example? let me try to ASCII draw you a picture:

T-R-A-I-L--<[OBJ]

trying to think of sort of a emition system, were the trail image 'spawns' at the tail of the emitor, and removes itself after a short amount of time. producing a trail effect, but i cant figure out how to make these spawned images not be cleared by the Cls command everyloop, if i tried somthing like the above it would just have 1 image at the emition point continusly due to the others being cleared..

hopefuly that makes sense?

You could use a Type, and give it a 'self-destruction countdown' Field. The [OBJ] could create these trail Type particles along the way, say, each 100 millisecs. For each new particle, the time is set to 500.
The particles count down their self-destruct time, and when it is zero, they Delete themself.

You mean like a matrix-style bullet trail?

Here is an example of a mouse trail.
Graphics 800,600,32,2
SetBuffer BackBuffer()

Type TTrail
	Field x# ;trail coordinate
	Field y#
	Field Time# ;time when trail deletes
End Type

While Not KeyHit(1)
	Cls
	MX# = MouseX() ;get current mouse coordinates
	MY# = MouseY()
	
	For Trail.TTrail = Each TTrail ;loop through trail
		If MilliSecs() > Trail\Time ;if time up, then delete trail
			Delete Trail
		Else
			TColor = (Trail\Time - MilliSecs())*255/3000 ;otherwise set color from white to black depending on how much time is left
			Color TColor,TColor,TColor
			Oval Trail\x-10,Trail\y-10,20,20 ;draw circle
		End If
	Next
	Color 255,255,255 ;make sure color is white again
	Oval MX-10,MY-10,20,20 ;draw cursor position
	
	Trail.TTrail = New TTrail ;save current cursor position in new trail
	Trail\x = MX
	Trail\y = MY
	Trail\Time = MilliSecs() + 3000 ;will delete in 3 seconds
	
	Flip False
Wend


ahh i see, thanks!