Particle Sprites
In these shots you can see that particle->mesh creation has been implemented in PlayBasic. Shot one has a single 1000 particle sprite, where shot #2 has 10 of them on screen.
Each particle has it's own local speed & force modifiers. But you'll also be able to set the size / UV mapping + rotation of each particle (2D&3D).
With rotation,the particle fragments can spin locally. This will make for some very interesting results. The down side of lots of contols is that Initializing a particle becomes a little more complex, plus there's more overhead per particle. But it'll certainly be worth the effort.
;setfps 75
Type PBposition
x#,y#,z#
EndType
; -------------------------------------------------------------------------------
; >> PB Particle Structure <<
; -------------------------------------------------------------------------------
Type PB_Particle_Modifier
Mode
x#,y#,z#
Accel as PBPosition
Min as PBPosition
Max as PBPosition
endtype
Type PB_Particle
TypeID
FrameCounter
MaxFrameCounter
Pos as PBPosition
Speed as PB_Particle_Modifier
Force as PB_Particle_Modifier
Scale as PB_Particle_Modifier
Angle as PBPosition
Colour
EndType
Dim Part as PB_Particle POinter
Part = new PB_Particle
load3dimage "LENS03.JPG",100
scaleimage 100,32,32,1
max=10
Dim ColourTable(Max)
NumbOfParticles=1000
For lp=1 to max
Spr=lp
CreateParticleSprite lp,NumbOfParticles
PositionSprite lp,0,0 ;rnd(400),rnd(300)
SpriteImage lp,100 ;+(lp&1)
PositionSpriteZ spr,10
SpriteDrawmode spr,2+16
ColourTable(lp)=rndrgb()
SpriteFAceQuantity lp,NumbOfParticles ;+100
For ThisPart=0 to NumbOfParticles
SetFace(lp,ThisPart,ThisPart*4,rndrgb())
next thispart
next
Do
Cls rgb(20,40,60)
Print Fps()
For lp=1 to max
Edges=rndRange(5,10)
Part.FrameCounter =0
Part.MaxFrameCounter =200
Part.Pos.z =10
Part.Colour =ColourTable(lp)
AngleStep#=360.0/Edges
BaseAngle#=rnd(360) ;GetSpriteAngle(lp)+70+Rnd(40)
Part.Force.X =0.0
Part.Force.Y =0.0
Part.Force.Z =0.0
SetPos(Part.Force.Accel,0,0.015,0)
SetPos(Part.Force.Max,0,20,0)
SetPos(Part.Force.Min,0,0,0)
MaxSpeed#=15
Part.Speed.Min.X =-(MaxSpeed#/2)
Part.Speed.Min.Y =-MaxSpeed#
Part.Speed.Max.X =MaxSpeed#/2
Part.Speed.Max.Y =MaxSpeed#
For MakeParts=0 to Edges-1
Part.Colour=rndrgb()
angle#=rnd#(360)
Xpos#=mousex()
Ypos#=Mousey()
Part.Pos.x=Xpos#
Part.Pos.Y=Ypos#
Speed#=rndrange#(1,6)
Part.Speed.X=CosRadius(Angle#,Speed#)
Part.Speed.Y=SinRadius(Angle#,Speed#)
Angle2#=angle#+180
Speed2#=Speed#/Part.MaxFrameCounter
Part.Speed.Accel.X=CosRadius(Angle2#,Speed2#)
Part.Speed.Accel.Y=SinRadius(Angle2#,Speed2#)
AddSpriteParticle lp,Part
next
; circle GetSpriteX(lp),GetSpriteY(lp),50,0
UpdateSpriteParticles lp
next
DrawOrderedSprites
FaceCount=0
For lp=1 to Max
FaceCount=FaceCount+GetSpritefaceQuantity(lp)
next
print FaceCount
Sync
loop
Function SetPos(me as PBposition Pointer,x#,y#,z#)
me.x=x#
me.y=y#
me.z=z#
EndFunction
Psub SetFace(ThisSprite,ThisFace,VertexOffset,ThisColour)
PokeSpriteFaceVerts ThisSprite,ThisFace,4
PokeSpriteface ThisSprite,ThisFace,0,VertexOffset+0,0,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,1,VertexOffset+1,1,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,2,VertexOffset+2,1,1,ThisColour
PokeSpriteface ThisSprite,ThisFace,3,VertexOffset+3,0,1,ThisColour
EndPsub
Note: This is sample code written for the current PB1.68h alpha, it's highly unlikely to the work in the future editions.
Note: Old Download removed (2010) visit
www.PlayBasic.com