How avoid to excced max num of particles?

Blitz3D Forums/Blitz3D Programming/How avoid to excced max num of particles?

Hi all,
I'm a registered user of Particle Candy,
trying to email to the author without success,
I need help with the next issue.

I have a world in which there are a lot of explosions
(imagine a bomb explosion).

In order to make the trials I have defined a key
to launch an explosion.

The method is simple: I create a new emitter each time
I press the 'explosion key'

The problem comes when, some time ago, after launched
some explosions (twenty, maybe, but not all simultaneosly),
the lib error comes "Max number of particles exceded, please, increase the ptnumparticles" (or something similar).

The problem is that even changing this number, the problem
will come, sooner or later, because if the number
pt_numparticles is just growing each time I create a new
emitter, changing that number the most I do is postpose
the error...

Sumarizing:

How could I put a lot of different explosions without
experiment this error?

Thanks in advance!

Are you sure it is 'Max number of particles'?

I can't find this error in the particle candy file but there is a 'Max number of particle types' error, you are probably getting this.

What you are probably doing is creating new particle types for every bomb you make e.g. flame type, smoke type etc.

You only need to create the particle types once, not for every bomb.

Thanks,
Yes, you are right, the error is referred to the
number of 'types' of particle.

I don't know how to avoid that.

If I don't create an emmiter for each bomb, how
should I do that?

The target is to have various explosions in secreen simultaneously.

I have tried somethings using "CopyParticleType"
(I don't know exactly if this has so much to do with the solution), without any success...

Could you please help pointing me in the right direction???

Thanks in advance.

OK, here is a simple demo.

Include "particle candy.bb"

Graphics3D 800,600,32
SetBuffer BackBuffer()

Global look=CreatePivot()
Global cam=CreateCamera(look)
PositionEntity cam,0,150,0
PointEntity cam,look

Dim Particle_Type(100); Up to 100 particle types
InitParticles(cam, "particles.png", 3)
Create_Particle_Types()

Global numemitters=0
Global lasttime=MilliSecs()

While Not KeyHit(1)


;make and explosion every 1/10th second 1000 times
If MilliSecs()-lasttime>100
If numemitters<1000
numemitters=numemitters+1
emitter=CreateEmitter()
Emitter_AddParticleType emitter, Particle_Type(0), 0,10000,20
Emitter_AddParticleType emitter, Particle_Type(1), 0,10000,20
Emitter_AddParticleType emitter, Particle_Type(2), 0,10000,20
Emitter_Start emitter
PositionEntity emitter,Rnd(-50,50),Rnd(-50,50),Rnd(-50,50)
lasttime=MilliSecs()
EndIf
EndIf 


UpdateParticles

TurnEntity look,1,1,1,1

UpdateWorld()
RenderWorld()
Text 0,0,"Emitters "+numemitters
Text 0,15,"Particles "+pt_numParticles
Flip



Wend

FreeParticleSystem ()


Function Create_Particle_Types% ()
;Red Smoke
Particle_Type(0) = CreateParticleType()
ParticleType_SetImage    		  Particle_Type(0),9
ParticleType_SetSpeed    		  Particle_Type(0),80,0
ParticleType_SetRandomSpeed	  Particle_Type(0),.02,0,.02
ParticleType_SetSize     		  Particle_Type(0),2,1,4,7
ParticleType_SetAlpha    		  Particle_Type(0),.5,.2,-.25
ParticleType_SetWeight   		  Particle_Type(0),0,0
ParticleType_SetRotation 		  Particle_Type(0),1,0
ParticleType_SetColor    		  Particle_Type(0),255,50,50,0,0,0,0
ParticleType_SetEmissionAngle Particle_Type(0),3,360
ParticleType_SetStartOffsets  Particle_Type(0),0,0,0,0,0,0
ParticleType_SetLifeTime 		  Particle_Type(0),250
ParticleType_SetAddedBlend    Particle_Type(0),0
;FireBall
Particle_Type(1) = CreateParticleType()
ParticleType_SetImage    		  Particle_Type(1),5
ParticleType_SetSpeed    		  Particle_Type(1),0,0
ParticleType_SetSize     		  Particle_Type(1),2,0,-2
ParticleType_SetAlpha    		  Particle_Type(1),1,0,0
ParticleType_SetWeight   		  Particle_Type(1),0,0
ParticleType_SetRotation 		  Particle_Type(1),1,0
ParticleType_SetColor    		  Particle_Type(1),255,255,200,0,-200,-200,-200
ParticleType_SetEmissionAngle Particle_Type(1),0,1
ParticleType_SetStartOffsets  Particle_Type(1),0,0,0,0,0,0
ParticleType_SetLifeTime 		  Particle_Type(1),2500
ParticleType_SetBounce        Particle_Type(1),0,0,0
ParticleType_SetPulsation     Particle_Type(1),4
ParticleType_SetAddedBlend    Particle_Type(1),0
; SPARKS
Particle_Type(2) = CreateParticleType()
ParticleType_SetImage    		  Particle_Type(2),1
ParticleType_SetSpeed    		  Particle_Type(2),15,5
ParticleType_SetSize     		  Particle_Type(2),.5,.15,-.5
ParticleType_SetAlpha    		  Particle_Type(2),1,.25,-.18
ParticleType_SetWeight   		  Particle_Type(2),2,0
ParticleType_SetRotation 		  Particle_Type(2),2,0
ParticleType_SetColor    		  Particle_Type(2),255,246,149,20,-150,-200,-150
ParticleType_SetEmissionAngle Particle_Type(2),3,360
ParticleType_SetStartOffsets  Particle_Type(2),0,0,0,0,0,0
ParticleType_SetLifeTime 		  Particle_Type(2),2000
ParticleType_SetBounce        Particle_Type(2),0,0,0
ParticleType_SetPulsation     Particle_Type(2),0
ParticleType_SetAddedBlend    Particle_Type(2),0
End Function


The key is to create an emitter for every bomb but do not create individual particles types for each bomb.

You only create the particle types once and then each emitter uses the same ones.

Thank you very much Shambler!

Sincerely, a lot of thanks for your help and your concern!
you rocks!
I've run your code and works perfectly! that's the stuff
I want to do!
Again, thank you very much for all.

Best regards,