News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Alpha Particles (Project pack example)

Started by kevin, July 27, 2017, 10:57:42 AM

Previous topic - Next topic

kevin


Alpha Particles (Project pack example)


    This is a repost (i think) of the alpha particle demo from the PLayBASIC learning edition project packs.


                       Released: 1st,Aug,2006




PlayBASIC Code: [Select]
; PROJECT : AlphaParticles
; AUTHOR : Kevin Picone (c) Underware Design 2005
; CREATED : 1/08/2006
; EDITED : 4/6/2010



OpenScreen 640,480,32,1
Randomize 42
MakeBitmapFont 1,$ffffff

setfps 60

sw=GetScreenWidth()
sh=GetScreenHeight()
Clipx2=sw-1
Clipy2=sh-1

; CReate an FX copy of the display
FXScreen=NewFXImage(sw,sh)


; create BlitIMage's blend surface.
BlendFXScreen=NewFXImage(sw,sh)
SetBlitImageBuffer BlendFXscreen
RenderToImage BlendFXScreen
ShadeBox 0,0,sw,sh,RndRGB(),RndRGB(),RndRGB(),RndRGB()


Path$=""
// #if PbCompileMode=0
Path$="..\..\gfx\"
//#Endif

RenderToScreen


; Projection constants
Constant ProjectionX#=400
Constant ProjectionY#=400

; View Z depth
Zdepth#=600


; Size of Alpha Texture
Size=24

MaxImages=64
Dim ParticleIMage(MaxImages)

Col=$ffffff
For lp=0 To MaxImages
ParticleIMage(lp)=NewImage(Size,Size)
RenderToImage ParticleIMage(lp)
PrepareFXImage ParticleIMage(lp)
RenderPhongImage ParticleIMage(lp),Size/2,Size/2,col,255,260/(size/2)
Col=RndRGB()
Next
RenderToScreen
ParticleSize=GetImageWidth(ParticleIMage(0))


NumberOfParticles=350

ACSet =1
Constant Particle_Xpos=AC(1)
Constant Particle_Ypos=AC(1)
Constant Particle_Zpos=AC(1)
Constant Particle_Sprite=AC(1)
Constant Particle_StructSize=AC(1)

Dim VertexList#(NumberOfParticles,Particle_StructSize)
Dim RotatedVertexList#(NumberOfParticles,Particle_StructSize)


ParticleSizeX#=30*ProjectionX#
ParticleSizeY#=30*ProjectionY#

Size=500
DRawmode=16
For lp=0 To NumberOfParticles
anglex#=Rnd(360)
angley#=Rnd(360)
anglez#=Rnd(360)
speed#=RndRange(50,size)
x#,y#,z#=CalcMovement(Anglex#,angley#,anglez#,Speed#)

VertexList#(lp,Particle_Xpos)=x#
VertexList#(lp,Particle_Ypos)=Y#
VertexList#(lp,Particle_Zpos)=Z#


ThisSprite=NewSprite(0,0,ParticleIMage(Rnd(MaxImages)))
SpriteDrawMode ThisSprite,2+DRawmode
; SpriteTransparent ThisSprite,Off
VertexList#(lp,Particle_Sprite)=ThisSprite
Next




Max=1000
VertSize =12

SrcBank=NewBank((NumberOfParticles+1)*VertSize)
DEstBank=NewBank((NumberOfParticles+1)*VertSize)


SrcAddress =GetBankPtr(SrcBank)
DestAddress =GetBankPtr(SrcBank)

For lp=0 To NumberOfParticles
PokeFloat SrcAddress,VertexList#(lp,Particle_Xpos)
PokeFloat SrcAddress+4,VertexList#(lp,Particle_Ypos)
PokeFloat SrcAddress+8,VertexList#(lp,Particle_Zpos)
SrcAddress=SrcAddress+12
Next



RenderMode=0


RenderToImage fxscreen
CreateCamera 1
CameraCls 1,Off

boxX2=100
boxY2=100


MaxEffectTime=5000

RenderToScreen


Type tVertex
x#,y#,z#
EndType

Dim VertexPointer As tVertex Pointer


Do

Inc frames
Login required to view complete source code