flashing sprites

Blitz3D Forums/Blitz3D Beginners Area/flashing sprites

Hi everybody,
I need to load flashing sprites in my 3d world (like stars, christmas lights, etc...). I read the filenames of the sprites form a file; each sprite has a different flashing time and position that I can't know until reading the file.

My problem is that I don't know how to handle the flashing behaviour: I don't want to control a timer in the main code for each sprite manually. (I don't know how many sprites there will be..) I would like each sprite has an independent flashing behaviour.

Does anybody have idea to how to do that?
I tried to use animated meshes (planes with textures) but I got some problems with transparency.

Thanks a lot,
fiNegiro


I don't want to control a timer in the main code for each sprite manually. (I don't know how many sprites there will be..) I would like each sprite has an independent flashing behaviour.


Use types, then you won't need to know how many in advance and the flashing can be handled 'manually automatically', if you follow. Quick example that you can surely improve upon:

Graphics3D 800,600,0,2
cam=CreateCamera()
SetBuffer BackBuffer()


Type flashyStar
	Field sprite
	Field flashCount
	Field flashIncrement
End Type
currentFlashyStar.flashyStar=Null

flashyStarTex=CreateTexture(64,64)
Oval 4,4,60,60,True
CopyRect 0,0,64,64,0,0,BackBuffer(),TextureBuffer(flashyStarTex)


For i=0 To 99
	currentFlashyStar=New flashyStar
	currentFlashyStar\sprite=CreateSprite()
	currentFlashyStar\flashCount=Rand(0,99)
	currentFlashyStar\flashIncrement=Rand(1,5)
	EntityTexture currentFlashyStar\sprite,flashyStarTex
	PositionEntity currentFlashyStar\sprite,Rnd(-100,100),Rnd(-100,100),100
Next

While Not KeyHit(1)

updateStars()

RenderWorld
Flip
Wend

Function updateStars()
	For currentFlashyStar.flashyStar=Each flashyStar
		currentFlashyStar\flashCount=currentFlashyStar\flashCount+currentFlashyStar\flashIncrement
		If currentFlashyStar\flashCount>99 Then currentFlashyStar\flashCount=currentFlashyStar\flashCount-100
		If currentFlashyStar\flashCount>49
			HideEntity	currentFlashyStar\sprite
		Else
			ShowEntity currentFlashyStar\sprite
		EndIf
	Next	
End Function 


Wonderful, I'm modifying my code this way.

Thanks Sledge