Page 1 of 1

Fountain upside down

Posted: Sat Aug 27, 2016 7:24 am
by DrChip

Code: Select all

REM Fountain efx
REM iPhone 6 Plus / iOS 10 beta 10
REM enjoy..

GRAPHICS
sw=SCREEN_WIDTH()
sh=SCREEN_HEIGHT()


Fountain:


maxdrops = RND(300)+10
gravity = -(RND(1)/10) 

xcenter  = sw/2
ycenter = sh/2

DIM x(maxdrops+1)
DIM y(maxdrops+1)
DIM vx(maxdrops+1)
DIM vy(maxdrops+1)
DIM t(maxdrops+1)
DIM col(maxdrops+1)

REM Init drops
FOR i=1 TO maxdrops
 x(i) = xcenter+RND(10)-5
 y(i) = ycenter+RND(10)-5
 vx(i) = RND(6)-3
 vy(i) = RND(8)
 t(i) = -RND(100) 
 col(i) = RND(255)
NEXT i


LOOP:
REFRESH OFF
GRAPHICS CLEAR 0,0,0
 FILL CIRCLE sw/2,sh/2 SIZE 5
 FOR i=1 TO maxdrops
  t(i) = t(i) + 1
  IF t(i) > 10000 THEN t(i)=0 
  
  IF t(i) > 0 THEN 
   x(i) = x(i) + vx(i)
   y(i) = y(i) + (vy(i) + (gravity*t(i)*t(i)))/2
   IF y(i) < 0 THEN 
    x(i) = xcenter+RND(10)-5
    y(i) = ycenter+RND(10)-5
    vx(i) = RND(6)-3
    vy(i) = RND(20)
    t(i) =  0
   END IF
   FILL COLOR (200+(ycenter-y(i)))/255,col(i)/255,(200-(xcenter-x(i)))/255
   FILL CIRCLE x(i),y(i) SIZE RND(1)+1
  END IF
 NEXT i
REFRESH ON
GOTO LOOP

Re: Fountain upside down

Posted: Mon Aug 29, 2016 5:41 am
by rbytes
Great effect. It is fun to change gravity and see the result. :D