REM ***********************************************
REM Title: Ripples
REM Author: 
REM Downloaded from: http://dbcc.zimnox.com/
REM ***********************************************
 
 
hide mouse
set camera range 1,5000
create bitmap 1,256,256
ink rgb(255,255,255),0
 
for i=0 to 1000
   dot int(rnd(256)),int(rnd(256))
next i
 
get image 2,0,0,255,255
set current bitmap 0
make object sphere 100,4000
texture object 100,2
scale object 100,-100,100,100
 
dim ripple(2,4)
 
make memblock 1,307212
write memblock dword 1,0,274
write memblock dword 1,4,32
write memblock dword 1,8,9600
 
for i=0 to 39
   for j=0 to 39:i#=i:j#=j
      for m=0 to 1
         write memblock float 1,12+((i+(j*40))*192)+0+(96*m),(i*50)-1000
         write memblock float 1,12+((i+(j*40))*192)+8+(96*m),(j*50)-1000
         write memblock float 1,12+((i+(j*40))*192)+24+(96*m),(i#/40)
         write memblock float 1,12+((i+(j*40))*192)+28+(96*m),(j#/40)
         write memblock float 1,12+((i+(j*40))*192)+0+64+(64*m),((i+1)*50)-1000
         write memblock float 1,12+((i+(j*40))*192)+8+64+(64*m),((j+1)*50)-1000
         write memblock float 1,12+((i+(j*40))*192)+24+64+(64*m),((i#+1)/40)
         write memblock float 1,12+((i+(j*40))*192)+28+64+(64*m),((j#+1)/40)
         write memblock float 1,12+((i+(j*40))*192)+0+32+(128*m),((i+(1*m))*50)-1000
         write memblock float 1,12+((i+(j*40))*192)+8+32+(128*m),((j+(1*(1-m)))*50)-1000
         write memblock float 1,12+((i+(j*40))*192)+24+32+(128*m),((i#+(1*m))/40)
         write memblock float 1,12+((i+(j*40))*192)+28+32+(128*m),((j#+(1*(1-m)))/40)
      next m
   next j
next i
 
make mesh from memblock 1,1
make mesh from memblock 2,1
meshflag=2
make object triangle 1,0,0,0,0,0,0,0,0,0
add limb 1,1,1
 
dim colours#(12)
 
for i=0 to 11
   colours#(i)=int(rnd(16))*0.5
next i
create bitmap 2,128,128
 
do
   coloura#=wrapvalue(coloura#+0.1)
   set current bitmap 2
 
   r1 = abs(sin(wrapvalue(coloura#*colours#(0)))+1)*127
   g1 = abs(sin(wrapvalue(coloura#*colours#(1)))+1)*127
   b1 = abs(sin(wrapvalue(coloura#*colours#(5)))+1)*127
 
   r2 = abs(sin(wrapvalue(coloura#*colours#(3)))+1)*127
   g2 = abs(sin(wrapvalue(coloura#*colours#(4)))+1)*127
   b2 = abs(sin(wrapvalue(coloura#*colours#(5)))+1)*127
 
   r3 = abs(sin(wrapvalue(coloura#*colours#(6)))+1)*127
   g3 = abs(sin(wrapvalue(coloura#*colours#(7)))+1)*127
   b3 = abs(sin(wrapvalue(coloura#*colours#(8)))+1)*127
 
   r4 = abs(sin(wrapvalue(coloura#*colours#(9)))+1)*127
   g4 = abs(sin(wrapvalue(coloura#*colours#(10)))+1)*127
   b4 = abs(sin(wrapvalue(coloura#*colours#(11)))+1)*127
 
   box 0,0,127,127,rgb(r1,g1,b1), rgb(r2,g2,b2), rgb(r3,g3,b3), rgb(r4,g4,b4)
 
   get image 1,0,0,127,127
   set current bitmap 0
   if int(rnd(20))=1
      if ripple(1,4)=0
         ripple(1,1)=int(rnd(1000))
         ripple(1,2)=int(rnd(1000))
         ripple(1,4)=1
      else
         if ripple(2,4)=0
            ripple(2,1)=int(rnd(1000))
            ripple(2,2)=int(rnd(1000))
            ripple(2,4)=1
         endif
      endif
   endif
 
   for k=1 to 2
      if ripple(k,4)<=150 and ripple(k,4)>0
         ripple(k,3)=wrapvalue(ripple(k,3)-5)
         ripple(k,4)=ripple(k,4)+1
         if ripple(k,4)=151
            ripple(k,4)=0
         endif
      endif
   next k
 
   for i=1 to 39
      for j=1 to 39
         for k=1 to 2
            if (sqrt((((i*25)-ripple(k,1))^2)+(((j*25)-ripple(k,2))^2)))>(ripple(k,4)*5)-540 and (sqrt((((i*25)-ripple(k,1))^2)+(((j*25)-ripple(k,2))^2)))<(ripple(k,4)*5)
               height# = height#+(2*(sin(2*(ripple(k,3)+sqrt((((i*25)-ripple(k,1))^2)+(((j*25)-ripple(k,2))^2))))*((150-ripple(k,4))/5)))
               heighta# = heighta#+(2*(sin(2*(ripple(k,3)+sqrt((((i*25)-(ripple(k,1)))^2)+(((j*25)-(ripple(k,2)+2))^2))))*((150-ripple(k,4))/5)))
               heightb# = heightb#+(2*(sin(2*(ripple(k,3)+sqrt((((i*25)-(ripple(k,1)))^2)+(((j*25)-(ripple(k,2)-2))^2))))*((150-ripple(k,4))/5)))
               heightc# = heightc#+(2*(sin(2*(ripple(k,3)+sqrt((((i*25)-(ripple(k,1)+2))^2)+(((j*25)-(ripple(k,2)))^2))))*((150-ripple(k,4))/5)))
               heightd# = heightd#+(2*(sin(2*(ripple(k,3)+sqrt((((i*25)-(ripple(k,1)-2))^2)+(((j*25)-(ripple(k,2)))^2))))*((150-ripple(k,4))/5)))
            endif
         next k
         for m=0 to 1
            write memblock float 1,12+((i+(j*40))*192)+12+(96*m),(0-(4*(heightd#-heightc#)))+(2*(i-(40*0.5)))
            write memblock float 1,12+((i+(j*40))*192)+16+(96*m),16
            write memblock float 1,12+((i+(j*40))*192)+20+(96*m),(0-((heightb#-heighta#)*4))+(2*(j-(40*0.5)))
            write memblock float 1,12+(((i-1)+((j-1)*40))*192)+12+64+(64*m),(0-(4*(heightd#-heightc#)))+(2*(i-(40*0.5)))
            write memblock float 1,12+(((i-1)+((j-1)*40))*192)+16+64+(64*m),16
            write memblock float 1,12+(((i-1)+((j-1)*40))*192)+20+64+(64*m),(0-((heightb#-heighta#)*4))+(2*(j-(40*0.5)))
            write memblock float 1,12+((i+(j*40))*192)+4+(96*m),height#
            write memblock float 1,12+(((i-1)+((j-1)*40))*192)+4+64+(64*m),height#
            write memblock float 1,12+(((i-(1*(m)))+((j-(1*(1-m)))*40))*192)+12+32+(128*m),(0-(4*(heightd#-heightc#)))+(2*(i-(40*0.5)))
            write memblock float 1,12+(((i-(1*(m)))+((j-(1*(1-m)))*40))*192)+16+32+(128*m),16
            write memblock float 1,12+(((i-(1*(m)))+((j-(1*(1-m)))*40))*192)+20+32+(128*m),(0-((heightb#-heighta#)*4))+(2*(j-(40*0.5)))
            write memblock float 1,12+(((i-(1*(m)))+((j-(1*(1-m)))*40))*192)+4+32+(128*m),height#
         next m
         height#=0:heighta#=0:heightb#=0:heightc#=0:heightd#=0
      next j
   next i
   change mesh from memblock meshflag,1
   if meshflag=1
      change mesh 1,1,1
      meshflag=2
   else
      change mesh 1,1,2
      meshflag=1
   endif
   set sphere mapping on 1,1
   position camera (cos((10*coloura#)+270)*(1000+(500*((cos((10*coloura#)*2)+2)*0.5)))),300+(sin((10*coloura#))*100),(sin((10*coloura#)+270)*(1000+500*(((cos((10*coloura#)*2)+2)*0.5))))
   point camera 0,200+(sin(20*coloura#)*50),0
   zrotate camera wrapvalue(sin((10*coloura#))*30)
loop