This is a basic 3d particle system for about 512 particles. But you can tweak all values as you want.
This is the shample code, no media needed.
You can test this functions in this game very well:
https://play.google.com/store/apps/details?id=com.onlinearts.island_simulator2014
Enjoy!
setVirtualResolution(getDeviceWidth(),getDeviceHeight())
setsyncrate(60,0)
SetCameraRange(1,1,3000)
SetCameraPosition(1,0,300,-500)
SetCamerarotation(1,0,0,0)
AddVirtualJoystick( 1, getDeviceHeight()/10,getDeviceHeight()-getDeviceHeight()/10,getDeviceHeight()/5)
level=createobjectplane(1800,1800)
setobjectrotation(level,90,0,0)
setobjectcolor(level,200,255,200,255)
type particle_def
obj as integer
col as integer
life as integer
x# as float
y# as float
z# as float
gravity as integer
XAcc# as float
YAcc# as float
ZAcc# as float
endtype
global particle as integer
global dim world_particles[512] as particle_def
init_particles()
particle_explosion(0,150,0,32,1,1)
Do
print("AGK Particles by Online Arts")
print("left mouseclick for explosion")
inc rainc
if rainc=3
rem x#,y#,z#, XAcc#,YAcc#,ZAcc#, amount,grav,col,life, sx#,sy#
particle_rain(oldx#,oldy#+800,oldz#,3,1,0)
rainc=0
endif
handle_particles()
if GetRawMouseLeftPressed()=1
particle_explosion(0,180,0,32,1,0)
endif
fps=ScreenFPS()
//////////////// Light Movements
if x#>=500
incX#=-10.0
elseif x#<=-500
incX#=10.0
endif
x#=x#+incX#
///////////////////////////////////////////////////////////////////////////////
/// Player Movements (Camera) /////////////////
oldx#=GetCameraX(1)
oldy#=GetCameraY(1)-25.0
oldz#=GetCameraZ(1)
RotateCameraLocalY(1,5*GetVirtualJoystickX( 1 ))
MoveCameraLocalZ(1,-20*GetVirtualJoystickY( 1 ))
newx#=GetCameraX(1)
newy#=GetCameraY(1)-45.0
newz#=GetCameraZ(1)
/// Collisions ///////////////////////////////////
if ObjectSphereSlide(0,oldx#,oldy#,oldz#,newx#,newy#,newz#,19.0)>0
newx#=GetObjectRayCastSlideX(0)
newy#=GetObjectRayCastSlideY(0)
newz#=GetObjectRayCastSlideZ(0)
SetCameraPosition(1,newx#,newy#+45.0,newz#)
endif
//////////////////////////////////////////////////
Render3D()
Render2DFront()
Swap()
if GetRawKeyPressed(27)=1 then exit
Loop
function particle_explosion(x#,y#,z#,amount,grav,col)
for i=1 to 512
if world_particles[i].life=0
world_particles[i].col=col
if col=1
setobjectcollisionmode(world_particles[i].obj,1)
else
setobjectcollisionmode(world_particles[i].obj,0)
endif
setobjectscale(world_particles[i].obj,1,1,1)
world_particles[i].x#=x#+random(1,10)
world_particles[i].y#=y#+random(1,10)
world_particles[i].z#=z#+random(1,10)
world_particles[i].life=random(200,400)
world_particles[i].YAcc#=random(8,20)
world_particles[i].XAcc#=random(10,20)-15
world_particles[i].ZAcc#=random(10,20)-15
if grav=1 then world_particles[i].gravity=1
inc am
if am=amount then exit
endif
next i
endfunction
function particle_rain(x#,y#,z#,amount,grav,col)
for i=1 to 512
if world_particles[i].life=0
world_particles[i].col=col
if col=1
setobjectcollisionmode(world_particles[i].obj,1)
else
setobjectcollisionmode(world_particles[i].obj,0)
endif
setobjectscale(world_particles[i].obj,0.1,1,1)
world_particles[i].x#=x#+random(1,2000)-1000
world_particles[i].y#=y#+random(1,400)-200
world_particles[i].z#=z#+random(1,2000)-1000
world_particles[i].life=200
world_particles[i].YAcc#=0
world_particles[i].XAcc#=0
world_particles[i].ZAcc#=0
if grav=1 then world_particles[i].gravity=1
inc am
if am=amount then exit
endif
next i
endfunction
function handle_particles()
for i=1 to 512
if world_particles[i].life>0
world_particles[i].life=world_particles[i].life-1
oldx# = world_particles[i].x#
oldy# = world_particles[i].y#
oldz# = world_particles[i].z#
x# = oldx# + world_particles[i].XAcc#
y# = oldy# + world_particles[i].YAcc#
z# = oldz# + world_particles[i].ZAcc#
if world_particles[i].XAcc#>0 then world_particles[i].XAcc#=world_particles[i].XAcc#-0.01
if world_particles[i].YAcc#>0 then world_particles[i].YAcc#=world_particles[i].YAcc#-0.01
if world_particles[i].ZAcc#>0 then world_particles[i].ZAcc#=world_particles[i].ZAcc#-0.01
if world_particles[i].gravity=1
world_particles[i].YAcc#=world_particles[i].YAcc#-0.1
endif
setobjectvisible(world_particles[i].obj,1)
setobjectposition(world_particles[i].obj,x#,y#,z#)
setobjectrotation(world_particles[i].obj,0,getcameraangley(1),0)
world_particles[i].x#=x#
world_particles[i].y#=y#
world_particles[i].z#=z#
if world_particles[i].col=1
if ObjectSphereSlide( world_particles[i].obj, oldx#, oldy#, oldz#, x#, y#, z#, 1 )
newx#=GetObjectRayCastSlideX( world_particles[i].obj )
newy#=GetObjectRayCastSlideY( world_particles[i].obj )
newz#=GetObjectRayCastSlideZ( world_particles[i].obj )
rem setobjectposition(world_particles[i].obj,oldx#, oldy#, oldz#)
setobjectposition(world_particles[i].obj,newx#, newy#, newz#)
endif
endif
else
setobjectvisible(world_particles[i].obj,0)
world_particles[i].x#=0
world_particles[i].y#=0
world_particles[i].z#=0
world_particles[i].XAcc#=0
world_particles[i].YAcc#=0
world_particles[i].ZAcc#=0
world_particles[i].gravity=0
endif
next i
endfunction
function init_particles()
for i=1 to 512
obj=createobjectplane(10,10)
inc particle
world_particles[particle].obj=obj
next i
endfunction