Particle Explosion v1.0

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Particle Explosion v1.0

Post by DrChip »

Code: Select all

REM
REM Particle Explosion v1.0
REM 

'screen area
sw = SCREEN_WIDTH()
sh = SCREEN_HEIGHT()
csw = sw/2
csh = sh/2

particles=100 'number of particles 
force=10 'brutal explosion!
ex=0 'x origin FOR blast
ey=0 'y origin FOR blast
aSET=0 'leave alone
DIM x(particles+1),y(particles+1),xd(particles+1),yd(particles+1)
GRAPHICS

LOOP:
REFRESH OFF
GRAPHICS CLEAR 0,0,0
'IF no explosion on screen set random co-ords
IF aSET=0 THEN 
    ex=RND(sw)
    ey=RND(sh)
END IF 
GOSUB explode
REFRESH ON
GOTO LOOP

explode:
rf=0
IF aSET=0 THEN
    rf=1
    aSET=255
    FOR a=1 TO particles
        x(a)=ex
        y(a)=ey
        xd(a)=-force+RND(force*2)
        yd(a)=-force+RND(force*2)
    NEXT a
END IF 

IF rf=1 THEN 
    RETURN 
END IF 
aSET=aSET-10 ' explosion timing
IF aSET<0 THEN
    aSET=0
END IF 
FOR a=1 TO particles
    FILL COLOR (aSET*a)/255,SET/255,SET/255 ' white to red fade
    FILL RECT x(a)-1,y(a)-1 TO x(a)+RND(5),y(a)+RND(5)
    x(a)=x(a)+xd(a)
    y(a)=y(a)+yd(a)
NEXT a
RETURN
Attachments
image.png
image.png (95.19 KiB) Viewed 6481 times
image.png
image.png (98.42 KiB) Viewed 6481 times
image.png
image.png (96.95 KiB) Viewed 6481 times

Post Reply