Partikelmanager modifiziert

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

stfighter01

Betreff: Partikelmanager modifiziert

BeitragMo, Dez 22, 2003 22:00
Antworten mit Zitat
Benutzer-Profile anzeigen
ich hab für mein game nen partikelmanager benötigt
und dazu hab ich den alten aus der sample blibliothek modifiziert
wenn ihn jemand haben will.

BlitzBasic: [AUSKLAPPEN]

;---------------------
;Particle Manager v1.0
; A.Gore 2001
; Redesigned by stfighter
;---------------------
;
;StartGuide:
; 1) Include this file in your main program
; 2) Use -InitParticleManager(FALSE)- after your Graphics3D command
; NOTE: you have always use -InitParticleManager(FALSE)- and create all your templates new
; after changing the screenmode
; 3) Insert -PM_Update()- before the RenderWorld command in your main loop
; 4) to create a new emitter use
; emitterhandle= PM_AddEmitter( templatehandle, x#, y#, z#, loop, parent, connectparent, connectparticle )
; emitterhandle: the handle of the new created emitter
; templatehandle: there are 6 predefined templates stored in -PM_DefaultTemplate[1-6]-
; it is possible To create new templates during the game
; x#,y#,z#: the relative koordinates of the particles to the emitter
; loop: if true, the emitter is spreading all the time
; if false, the emitter is generate a single shower of particles and vanishes with the last particle
; parent: a optional parent entity where the emitter is connected
; connectparticle: if true, the particles are childs of the emitter
; connectparent: if false the emitter is not a child of the parent entity, but use the startposition of the parent

;Creating New Templates:
; 1) to add a new template in the default template list
; Increase the -PM_StandartTemplates- variable To the New amount of Templates
; After this, add the new template data at the bottom of the TEMPLATE DATA LIST
; 2) to create a new template in the mainprogramm
; to define the template use following commands
; PM_SetTemplateSprite( filename$, blend, fade )
; filename: spritemap (should be gray) for the particles
; if filename = \"\" the the standard sprite will be used
; blend: particle blend mode
; fade: if true, the particle fades out
; PM_SetTemplateTime( min#, max# )
; the particle time
; PM_SetTemplateSize( xsize#, ysize# )
; the particle size
; PM_SetTemplateVelocity( minvx#, maxvx#, minvy#, maxvy#, minvz#, maxvz#, gravity#)
; minvx(y,z),maxvx(y,z): the startspeed of the particles is a value between min,max
; gravity: no ex
; PM_SetTemplateParticles( nopart )
; particle spread rate
; PM_SetTemplateColors( startred#,startgreen#,startblue# ,endred#, endgreen#, endblue# )
; during the fly, the particle fades from the startcolor to the endcolor
; PM_SetTemplatePosition( minx#, maxx#, miny#, maxy#, minz#, maxz#)
; startposition of the particles relative to the emitter is a random value between min, max
; PM_SetTemplateRotation( rot# )
; the rotation speed of the particles
; PM_SetTemplateDefault( )
; set all this options back to default (maybe useful to call before making a new template )
; templatehandle= PM_CreateTemplate()
; Creates a new template with the defined options and return its handle
;
;some hints:
; you cannot delete an entity which is used as parent by an emitter, because this result in an crash
; use -PM_DisconnectEmitter( emitterhandle )- before to make the emitter free from your entity
; use -PM_ConnectEmitter(emitterhandle, parent, changeposition)- to connect it to a new parent


;-----------------------------------------------------------------------------------------
;VARIBLES
;-----------------------------------------------------------------------------------------

Const PM_StandartTemplates= 6


Type Particle
Field entity ;entity
Field vectors#[4] ;velocity vectors
Field colors#[6] ;colors
Field age#, maxage# ;age
Field fade
Field emitter.emitter
Field rotation#,angle#
End Type

Type Emitter
Field emitpos#[3] ;position the particles are emitted from
Field entity ;optional parent entity
Field loop ;true - particles are reset after destroyed
Field templateid ;the template to get particle characteristics from
Field particletimer#
Field particle.Particle ;the first particle of the emiter
Field timer
Field connectparticles
End Type

Type Template ;stores list of emitter templates
Field sprite ;sprite entity
Field gravity# ;amount of gravity applied to y velocity
Field viewmode
Field minage,maxage ;age at which the particles are destroyed rnd(min,max)
Field fade ;true - particles fade away
Field nopart# ;number of particles to use (must not be more than max_particles)
Field positions#[6]
Field vectors#[6]
Field colors[6]
Field rotation#
End Type

Global PM_DefaultTemplate[PM_StandartTemplates-1]

Global PM_FirstUse
Global PM_ActiveTemplatePosition
Global PM_DefaultTexture

Global PM_TemplateBlend
Global PM_TemplateGravity#
Global PM_TemplateMinAge#
Global PM_TemplateMaxAge#
Global PM_TemplateXSize#
Global PM_TemplateYSize#
Global PM_TemplateFade
Global PM_TemplateColor#[3]
Global PM_TemplateColorM#[3]
Global PM_TemplateNrOfParticles#
Global PM_TemplatePosition#[6]
Global PM_TemplateSpeed#[6]
Global PM_TemplateRotation#
Global PM_TemplateFileName$

;-----------------------------------------------------------------------------------------
;FUNCTIONS
;-----------------------------------------------------------------------------------------


Function PM_SetTemplateSprite( filename$, blend, fade )

PM_TemplateBlend= blend
PM_TemplateViewMode= 1
PM_TemplateFade= fade
PM_TemplateFileName= filename$

End Function

;----------------------------------------

Function PM_SetTemplateTime( min#, max# )

PM_TemplateMinAge#= min
PM_TemplateMaxAge#= max

End Function

;----------------------------------------

Function PM_SetTemplateSize( xsize#, ysize# )

PM_TemplateXSize#= xsize
PM_TemplateYSize#= ysize

End Function

;----------------------------------------

Function PM_SetTemplateVelocity( minvx#, maxvx#, minvy#, maxvy#, minvz#, maxvz#, gravity#)

PM_TemplateSpeed[1]= minvx#
PM_TemplateSpeed[2]= maxvx#

PM_TemplateSpeed[3]= minvy#
PM_TemplateSpeed[4]= maxvy#

PM_TemplateSpeed[5]= minvz#
PM_TemplateSpeed[6]= maxvz#

PM_TemplateGravity#= gravity

End Function


;----------------------------------------

Function PM_SetTemplateParticles( nopart )

PM_TemplateNrOfParticles= nopart

End Function

;----------------------------------------


Function PM_SetTemplateColors( red#,green#,blue# ,mred#, mgreen#, mblue# )

PM_TemplateColor[1]= red
PM_TemplateColor[2]= green
PM_TemplateColor[3]= blue

PM_TemplateColorM[1]= mred
PM_TemplateColorM[2]= mgreen
PM_TemplateColorM[3]= mblue

End Function

;----------------------------------------


Function PM_SetTemplatePosition( minx#, maxx#, miny#, maxy#, minz#, maxz#)

PM_TemplatePosition[1]= minx
PM_TemplatePosition[2]= maxx

PM_TemplatePosition[3]= miny
PM_TemplatePosition[4]= maxy

PM_TemplatePosition[5]= minz
PM_TemplatePosition[6]= maxz

End Function

;----------------------------------------


Function PM_SetTemplateRotation( rot# )

PM_TemplateRotation#= rot

End Function


;----------------------------------------


Function PM_SetTemplateDefault( )

PM_TemplateBlend= 3
PM_TemplateViewMode= 1
PM_TemplateGravity#= 0.01
PM_TemplateMinAge#= 20
PM_TemplateMaxAge#= 100
PM_TemplateXSize#= 10
PM_TemplateYSize#= 10
PM_TemplateFade= True
PM_TemplateColor[1]= 255
PM_TemplateColor[2]= 255
PM_TemplateColor[3]= 255

PM_TemplateColorM[1]= 1
PM_TemplateColorM[2]= 1
PM_TemplateColorM[3]= 1

PM_TemplateNrOfParticles= 20

PM_TemplatePosition[1]= 0
PM_TemplatePosition[2]= 0
PM_TemplatePosition[3]= 0
PM_TemplatePosition[4]= 0
PM_TemplatePosition[5]= 0
PM_TemplatePosition[6]= 0

PM_TemplateSpeed[1]= 1
PM_TemplateSpeed[2]= 2
PM_TemplateSpeed[3]= 1
PM_TemplateSpeed[4]= 2
PM_TemplateSpeed[5]= 1
PM_TemplateSpeed[6]= 2

PM_TemplateRotation#= 0
PM_TemplateFileName= \"\"


End Function




;----------------------------------------
;
;----------------------------------------


Function PM_ReadDefaultTexture()
Local x,y,gray, xsize,ysize



PM_DefaultTexture= CreateTexture(16,16)
SetBuffer TextureBuffer(PM_DefaultTexture)
Restore sparkdata

Read xsize, ysize

For y = 0 To xsize-1
For x= 0 To ysize-1
Read gray

Color gray,gray,gray
Plot x,y
Next

Next

SetBuffer BackBuffer()

End Function

;----------------------------------------
;
;----------------------------------------


Function PM_CreateSprite()
Local sprite
sprite= CreateSprite()
EntityTexture sprite, PM_DefaultTexture
Return sprite
End Function

;----------------------------------------
;
;----------------------------------------


Function PM_CreateTemplate()

Local viewmode,t,ptemplate.template

t= PM_ActiveTemplatePosition
PM_ActiveTemplatePosition= PM_ActiveTemplatePosition+1

ptemplate.template = New Template

ptemplate\viewmode= PM_TemplateViewMode
ptemplate\gravity= PM_TemplateGravity#
ptemplate\minage= PM_TemplateMinAge#
ptemplate\maxage= PM_TemplateMaxAge#
ptemplate\fade= PM_TemplateFade

ptemplate\colors[1]= PM_TemplateColor[1]
ptemplate\colors[2]= PM_TemplateColor[2]
ptemplate\colors[3]= PM_TemplateColor[3]

ptemplate\colors[4]= PM_TemplateColorM[1]
ptemplate\colors[5]= PM_TemplateColorM[2]
ptemplate\colors[6]= PM_TemplateColorM[3]

ptemplate\nopart= ( PM_TemplateNrOfParticles / ( PM_TemplateMinAge# + PM_TemplateMaxAge# ) ) / 2

ptemplate\positions[1]= PM_TemplatePosition[1]
ptemplate\positions[2]= PM_TemplatePosition[2]

ptemplate\positions[3]= PM_TemplatePosition[3]
ptemplate\positions[4]= PM_TemplatePosition[4]

ptemplate\positions[5]= PM_TemplatePosition[5]
ptemplate\positions[6]= PM_TemplatePosition[6]


ptemplate\vectors[1]= PM_TemplateSpeed[1]
ptemplate\vectors[2]= PM_TemplateSpeed[2]

ptemplate\vectors[3]= PM_TemplateSpeed[3]
ptemplate\vectors[4]= PM_TemplateSpeed[4]

ptemplate\vectors[5]= PM_TemplateSpeed[5]
ptemplate\vectors[6]= PM_TemplateSpeed[6]

ptemplate\rotation= PM_TemplateRotation

If PM_TemplateFileName = \"\"
ptemplate\sprite= PM_CreateSprite()
Else
ptemplate\sprite = LoadSprite( PM_TemplateFileName ) ;pre-load all sprites.
EndIf
EntityBlend ptemplate\sprite,PM_TemplateBlend
; If ptemplate[t]\viewmode = 4 Then viewmode = 2 Else viewmode = ptemplate[t]\viewmode
; SpriteViewMode ptemplate[t]\sprite,viewmode
SpriteViewMode ptemplate\sprite,1

ScaleSprite ptemplate\sprite,PM_TemplateXSize#,PM_TemplateYSize#
RotateSprite ptemplate\sprite,PM_TemplateRotation#
HideEntity ptemplate\sprite

Return Handle(ptemplate)
End Function


;----------------------------------------
;
;----------------------------------------


Function PM_ReadStandartTemplates()

Local t,filename$,blend,viewmode,xsize#,ysize#,rot#

Restore sparks0

For t = 0 To PM_StandartTemplates-1

Read PM_TemplateFileName$
Read PM_TemplateBlend
Read PM_TemplateViewMode
Read PM_TemplateGravity#
Read PM_TemplateMinAge#, PM_TemplateMaxAge#
Read PM_TemplateXSize#, PM_TemplateYSize#
Read PM_TemplateFade
Read PM_TemplateColor[1],PM_TemplateColor[2],PM_TemplateColor[3]
Read PM_TemplateColorM[1], PM_TemplateColorM[2], PM_TemplateColorM[3]
Read PM_TemplateNrOfParticles
Read PM_TemplatePosition[1], PM_TemplatePosition[2]
Read PM_TemplatePosition[3], PM_TemplatePosition[4]
Read PM_TemplatePosition[5], PM_TemplatePosition[6]
Read PM_TemplateSpeed[1], PM_TemplateSpeed[2]
Read PM_TemplateSpeed[3], PM_TemplateSpeed[4]
Read PM_TemplateSpeed[5], PM_TemplateSpeed[6]
Read PM_TemplateRotation#

; PM_ActiveTemplatePosition= PM_MaxTemplates+t
PM_DefaultTemplate[t]= PM_Createtemplate()
Next

End Function

;----------------------------------------
;
;----------------------------------------



Function PM_AddEmitter(t, xpos#,ypos#,zpos#, loop, parent, connectparent, connectparticles)
Local nopart,i

If Object.template(t)= Null : Return 0 : EndIf

e.Emitter= New Emitter

If parent = 0
e\entity= CreatePivot()
PositionEntity e\entity, xpos,ypos,zpos
Else
e\entity= CreatePivot(parent)
MoveEntity e\entity, xpos, ypos, zpos
If connectparent= False : EntityParent e\entity,0 : EndIf
EndIf


e\emitpos[1]= xpos
e\emitpos[2]= ypos
e\emitpos[3]= zpos
e\loop= loop
e\templateid= t
e\particletimer= 0
e\particle= Null
e\timer= 0
e\connectparticles= connectparticles
Return Handle(e)

End Function

;----------------------------------------
;
;----------------------------------------


Function PM_RemoveEmitter(ehandle ,removeparticles)
e.emitter= Object.emitter(ehandle)
If e.emitter= Null Return

p.particle= e\particle

While p<> Null
If p\emitter <> e Exit
p2.particle= After p
If removeparticles
FreeEntity p\entity
Delete p
Else
p\emitter= Null
EntityParent p\entity,0
EndIf

p= p2
Wend

FreeEntity e\entity
Delete e
End Function

;----------------------------------------
;
;----------------------------------------

Function PM_DisconnectEmitter(ehandle)
e.emitter= Object.emitter(ehandle)
If e.emitter= Null Return

EntityParent e\entity, 0
End Function

;----------------------------------------
;
;----------------------------------------

Function PM_ConnectEmitter(ehandle, parent, changeposition)

e.emitter= Object.emitter(ehandle)
If e.emitter= Null Return

If changeposition
PositionEntity e\entity, EntityX(parent), EntityY(parent), EntityZ(parent)
RotateEntity e\entity, EntityPitch(parent), EntityYaw(parent), EntityYaw(parent)
EntityParent e\entity, parent
EndIf

End Function

;----------------------------------------
;
;----------------------------------------

Function PM_Update()
Local time#,red#,green#,blue#,i,ptemplate.template


For e.Emitter= Each Emitter
ptemplate.template= Object.template(e\templateid)

If e\loop= True
e\particletimer= e\particletimer+ptemplate\nopart
Else
If e\timer= 0
e\particletimer= ptemplate\nopart * (ptemplate\maxage+ptemplate\minage) /2
EndIf
e\timer= e\timer+1
EndIf

While e\particletimer > 1
e\particletimer= e\particletimer-1

If e\particle.particle= Null
e\particle.Particle= New particle
p.particle= e\particle.Particle
Else
p.particle= New particle
Insert p After e\particle
EndIf

p\emitter.emitter= e.emitter

;sprite kopieren und an position setzten
p\entity = CopyEntity( ptemplate\sprite, e\entity )
If e\connectparticles= False
EntityParent p\entity,0
EndIf

;geschwindigkeit festlegen

p\vectors[1]= Rnd(ptemplate\vectors[1], ptemplate\vectors[2])
p\vectors[2]= Rnd(ptemplate\vectors[3], ptemplate\vectors[4])
p\vectors[3]= Rnd(ptemplate\vectors[5], ptemplate\vectors[6])

p\vectors[4]= ptemplate\gravity

p\age= 0
p\maxage= Rnd( ptemplate\minage, ptemplate\maxage )
p\rotation= ptemplate\rotation
p\fade= ptemplate\fade
For i= 1 To 6 :p\colors[i]= ptemplate\colors[i]: Next

Wend

If e\timer > ptemplate\maxage
PM_RemoveEmitter(Handle(e),True)
EndIf

Next


For p.particle= Each particle
p\age= p\age+1
If p\age < p\maxage
MoveEntity p\entity, p\vectors[1], p\vectors[2], p\vectors[3]

If p\rotation <> 0
p\angle= (p\angle+p\rotation) Mod 360
RotateSprite p\entity, p\angle
EndIf
p\vectors[2]= p\vectors[2]- p\vectors[4]
time= p\age/p\maxage
red#= p\colors[1] + (p\colors[4]-p\colors[1])* time
green#= p\colors[2] + (p\colors[5]-p\colors[2])* time
blue#= p\colors[3] + (p\colors[6]-p\colors[3])* time

EntityColor p\entity, red#,green#,blue#
If p\fade
EntityAlpha p\entity, 1-time
EndIf
Else
If p\emitter <> Null
If p\emitter\particle= p
newparticle.particle= p\emitter\particle
newparticle.particle= After newparticle
If newparticle <> Null
If newparticle\emitter= p\emitter
p\emitter\particle= newparticle
Else
p\emitter\particle= Null
EndIf
Else
p\emitter\particle= Null
EndIf

EndIf
EndIf

FreeEntity p\entity
Delete p

EndIf


Next

End Function

;----------------------------------------
;
;----------------------------------------

Function InitParticleManager(clearentitys) ;set this on true if you havn't cleared the old 3D objects before
Local i, ptemplate.template, e.emitter, p.particle

If clearentitys
If PM_DefaultTexture <> 0
FreeTexture PM_DefaultTexture
EndIf

For ptemplate.template= Each template
If ptemplate\sprite <> 0
FreeEntity ptemplate\sprite
EndIf
Next

For e.emitter= Each emitter
If e\entity <> 0
FreeEntity e\entity
EndIf
Next
For p.particle= Each particle
If p\entity <> 0
FreeEntity p\entity
EndIf
Next
EndIf

For ptemplate.template= Each template
Delete ptemplate
Next

For e.emitter= Each emitter
Delete e
Next
For p.particle= Each particle
Delete p
Next


PM_ReadDefaultTexture()
PM_ReadStandartTemplates()
End Function


;----------------------------------------------------------------------------------------
; STANDART SPARK IMAGE
;----------------------------------------------------------------------------------------

.sparkdata
Data 16, 16
Data 5, 6, 5, 5, 10, 3, 3, 7, 7, 6, 4, 5, 4, 3, 3, 4
Data 2, 13, 15, 15, 15, 12, 10, 25, 15, 19, 15, 14, 12, 12, 12, 8
Data 6, 7, 21, 29, 27, 34, 26, 39, 22, 43, 38, 27, 23, 23, 16, 9
Data 3, 15, 15, 37, 51, 43, 40, 52, 42, 54, 43, 45, 41, 22, 12, 3
Data 7, 11, 26, 34, 56, 65, 72, 67, 73, 67, 62, 60, 45, 27, 16, 9
Data 4, 16, 37, 51, 58, 87, 93, 94,105, 93, 89, 66, 48, 38, 21, 6
Data 4, 7, 26, 44, 78, 95,140,158,164,145,103, 78, 52, 42, 17, 5
Data 6, 18, 35, 46, 61,100,171,232,236,185,112, 72, 51, 32, 19, 7
Data 7, 16, 35, 53, 81,117,187,248,250,189,111, 78, 58, 38, 23, 10
Data 8, 14, 32, 45, 61, 97,163,215,205,165,100, 68, 47, 33, 19, 8
Data 1, 4, 21, 46, 75, 91,116,138,118,107, 92, 72, 42, 31, 9, 6
Data 4, 14, 31, 48, 60, 74, 87, 87, 77, 62, 71, 59, 49, 19, 15, 6
Data 9, 14, 22, 34, 50, 52, 56, 61, 49, 46, 42, 50, 31, 26, 12, 4
Data 3, 11, 15, 28, 27, 35, 35, 37, 31, 33, 19, 24, 25, 19, 18, 6
Data 4, 9, 15, 15, 20, 18, 15, 14, 8, 15, 9, 9, 14, 15, 11, 9
Data 2, 7, 8, 6, 8, 2, 2, 4, 4, 7, 5, 1, 4, 1, 5, 6

;-----------------------------------------------------------------------------------------
;TEMPLATE DATA
;-----------------------------------------------------------------------------------------

.sparks0

Data \"\" ;filename
Data 3 ;blendmode 1-alpha 2-multiply 3-add
Data 1 ;viewmode 1=faces camera, 4=independant of camera except yaw
Data 0 ;gravity
Data 30,30 ;max age rnd(min,max)
Data 2,2 ;sprite size
Data True ;fade true/false
Data 255,255,0 ;start color r g b
Data 0,-5,0 ;color mutiplier r g b (endcol = colrgb + (colmrgb * maxage))
Data 30 ;number of particles to use
Data 0,0 ;x starting min max position offset
Data 0,0 ;y
Data 0,0 ;z
Data -2,2 ;vx starting min max velocity
Data -2,2 ;vy
Data -2,2 ;vz
Data 0 ;rotation of particles

.rain1

Data \"\" ;filename
Data 3 ;blendmode 1-alpha 2-multiply 3-add
Data 4 ;viewmode 1=faces camera, 4=independant of camera except yaw
Data 1 ;gravity
Data 10,20 ;max age rnd(min,max)
Data .3,10 ;sprite size
Data 0 ;fade true/false
Data 255,255,255 ;color r g b
Data 10,0,0 ;color mutiplier r g b
Data 200 ;number of particles to use
Data -250,250 ;x starting min max position offset
Data 0,0 ;y
Data -250,250 ;z
Data 0,0 ;vx starting min max velocity
Data -8,-8 ;vy
Data 0,0 ;vz
Data 0 ;rotation of particles

.fire2

Data \"\" ;filename
Data 3 ;blendmode 1-alpha 2-multiply 3-add
Data 4 ;viewmode 1=faces camera, 4=independant of camera except yaw
Data 0 ;gravity
Data 10,50 ;max age
Data 1,4 ;sprite size
Data True ;fade true/false
Data 255,255,0 ;color r g b
Data -5,-10,0 ;color mutiplier r g b
Data 16 ;number of particles to use
Data -.5,.5 ;x starting min max position offset
Data -.5,.5;0,0 ;y
Data -.5,.5;0,0 ;z
Data -.05,.05 ;vx starting min max velocity
Data .2,.3 ;vy
Data -.05,.05 ;vz
Data 0 ;rotation of particles

.magic3

Data \"\" ;filename
Data 3 ;blendmode 1-alpha 2-multiply 3-add
Data 1 ;viewmode 1=faces camera, 4=independant of camera except yaw
Data 0.01 ;gravity
Data 50,250 ;max age rnd(min,max)
Data 4,4 ;sprite size
Data True ;fade true/false
Data 0,255,0 ;color r g b
Data 155,200,100 ;color mutiplier r g b
Data 100 ;number of particles to use
Data -5,5 ;x starting min max position offset
Data -5,5 ;y
Data -5,5 ;z
Data -.1,.1 ;vx starting min max velocity
Data -.1,.1 ;vy
Data -.1,.1 ;vz
Data 2 ;rotation of particles

.fountain4

Data \"\" ;filename
Data 3 ;blendmode 1-alpha 2-multiply 3-add
Data 1 ;viewmode 1=faces camera, 4=independant of camera except yaw
Data .2 ;gravity
Data 25,50 ;max age rnd(min,max)
Data 5,5 ;sprite size
Data False ;fade true/false
Data 255,255,0 ;color r g b
Data 132,5,140 ;color mutiplier r g b
Data 400 ;number of particles to use
Data 0,0 ;x starting min max position offset
Data -12,-12 ;y
Data 0,0 ;z
Data -1.5,1.5 ;vx starting min max velocity
Data 4,6 ;vy
Data -1.5,1.5 ;vz
Data 0 ;rotation of particles

.firesparks5

Data \"\" ;filename
Data 3 ;blendmode 1-alpha 2-multiply 3-add
Data 1 ;viewmode 1=faces camera, 4=independant of camera except yaw
Data .001 ;gravity
Data 20,100 ;max age rnd(min,max)
Data .1,.1 ;sprite size
Data True ;fade true/false
Data 255,128,0 ;color r g b
Data 0,0,0 ;color mutiplier r g b
Data 4 ;number of particles to use
Data -.5,.5 ;x starting min max position offset
Data 0,0 ;y
Data -.5,.5 ;z
Data -.1,.1 ;vx starting min max velocity
Data .1,.2 ;vy
Data -.1,.1 ;vz
Data 0 ;rotation of particles



und zum veranschaulichen gibs noch ein demo program dazu


BlitzBasic: [AUSKLAPPEN]

Include \"particlemanager.bb\"

;benutze linke maustaste um emitter zu erzeugen
;benutze leer- und linke maustaste um anderen emitter zu erzeugen
;benutze rechte maustaste um emitter zu löschen
;benutze mittlere maustaste um zuletzt erzeugen emitter an position der maus zu setzen

Graphics3D 640,480,16,2
InitParticleManager(True)

Global i= 1,emitt

cam= CreateCamera()
MoveEntity cam, 0,0,-160

Dim emitter(1000)

mouse= CreateSphere()
ScaleEntity mouse, 4,4,4

Global magictemplate


PM_SetTemplateSprite( \"\", 3, True )
PM_SetTemplateTime( 50, 250 )
PM_SetTemplateSize( 20, 20 )
PM_SetTemplateVelocity( -0.4, 0.4,-0.4, 0.4,-0.4, 0.4, 0.01)
PM_SetTemplateParticles( 100 )
PM_SetTemplateColors( 0,255,0 ,155, 200, 100 )
PM_SetTemplatePosition( -20, 20,-20, 20, -20, 20)
PM_SetTemplateRotation( 1 )
magictemplate= PM_CreateTemplate()


HidePointer

While Not KeyHit(1)

If MouseHit(1)
If i < 1000
i= i+1
If KeyDown(57)
emitter(i)= PM_AddEmitter(magictemplate,0,0,0,True, mouse, True, False)
Else
emitter(i)= PM_AddEmitter(PM_DefaultTemplate[4],0,0,0,True, mouse, True, False)
EndIf
EndIf
EndIf


If MouseHit(2)
If (i > 1)

PM_RemoveEmitter(emitter(i), False)

i= i-1
EndIf
EndIf
If MouseHit(3)
PM_Disconnectemitter(emitter(i))
EndIf


PositionEntity mouse, (MouseX()-320.0)/2.0,-(MouseY()-240.0)/2.0,0




PM_Update()
RenderWorld : Flip
Wend


ich hoffe die modifikation nützt euch was.

mfg stfighter

p.s.: ich lehne alle rechte an diesem programm ab, ich hab es nicht geschrieben, sondern nur modifiziert, daher ist es nicht mein, sondern das program von A.Gore
Denken hilft!

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group