'=========================================================================== ' Subject: ANOTHER MOVING LIGHT SIMULATION Date: 03-17-99 (13:15) ' Author: Jacob Wieles Code: QB, QBasic, PDS, PB ' Origin: jacwls@worldonline.nl Packet: GRAPHICS.ABC '=========================================================================== 'program : MOTION-2.BAS (16-03-99) ' Playing with a look-a-like Penrose & Penrose stairs ' and simulation of moving lights stairs down with data ' change in the DAC (Digital Analog Converter) 'which basic : PowerBASIC and Q(uick)BASIC 'auteur : Jacob Wieles defint a-z ix=8 iy=4 x1=ix:x2=2*ix:x3=3*ix:x4=4*ix:x5=5*ix y1=iy:y2=2*iy:y3=3*iy:y4=4*iy:y5=5*iy:y6=6*iy:y8=8*iy gosub initdrawstrings screen 12 gosub initialcolor gosub stairs color 1 locate 1,1 print" Hit a key for go down." keyhit$=input$(1) gosub simulation gosub MakeColorsLight while inkey$<>"":wend locate 1,1 print" Hit a key for end. " hitakey$=input$(1) cls screen 0 w!=timer while timer14 then pset(px,py),1 draw f5$ paint(px,py-y6),2+i mod 4,1 'top paint(px-1,py+y3),6+i mod 4,1 'left paint(px+2,py),10+i mod 4,1 'right end if case 24 px=px+x4 py=py-y2 pset(px,py),1 draw f6$ paint(px,py-y6),2+i mod 4,1 'top paint(px-1,py+y3),6+i mod 4,1 'left paint(px+2,py),10+i mod 4,1 'right case 25 to 27 px=px+x4 py=py+y6 pset(px,py),1 draw f7$ paint(px,py-2),2+i mod 4,1 'top paint(px-2,py),6+i mod 4,1 'left paint(px+2,py),10+i mod 4,1 'right case 28 px=px+x4 py=py+y6 pset(px,py),1 draw f8$ paint(px,py-2),2+i mod 4,1 'top paint(px-2,py),6+i mod 4,1 'left paint(px+2,py),10+i mod 4,1 'right case 29 to 31 px=px-x4 py=py+y6 pset(px,py),1 draw f8$ paint(px,py-2),2+i mod 4,1 'top paint(px-2,py),6+i mod 4,1 'left paint(px+2,py),10+i mod 4,1 'right end select next i return initialcolor: call NewPaletteUsing '===>>> PB set AC (0-15) to (0-15) call SetColor(0,0,0,1) 'Color 1 : Black call SetColor(63,63,63,0) 'Background color White call SetColor(0,50,0,16) 'DAC (16) color Green call SetColor(50,0,0,17) 'DAC (17) color Red call SetColor(0,0,50,18) 'DAC (18) color Blue call SetColor(0,63,0,19) 'DAC (19) color Light green call SetColor(63,0,0,20) 'DAC (20) color Light red call SetColor(0,0,63,21) 'DAC (21) color Light blue for i=2 to 5 '4 x paint-color for top >> Green call ChangeColor(16,i) 'color 2-5 next i for i=6 to 9 '4 x paint-color for left >> Red call ChangeColor(17,i) 'color 6-9 next i for i=10 to 13 '4 x paint-color for right >> Blue call ChangeColor(18,i) 'color 10-13 next i return MakeColorslight: for i=2 to 5 call ChangeColor(19,i) next i for i=6 to 9 call ChangeColor(20,i) next i for i=10 to 13 call ChangeColor(21,i) next i return simulation: dt!=.2 ' try an other value do locate 1,1 print" Hit spacebar for stop."; print" " do for i=0 to 3 call ChangeColor(19,2+i) '\ call ChangeColor(20,6+i) '| Make the colors of the boxes light call ChangeColor(21,10+i) '/ call ChangeColor(16,5-(4-i) mod 4) '\ call ChangeColor(17,9-(4-i) mod 4) '| Make the colors dark call ChangeColor(18,13-(4-i) mod 4) '/ t!=timer while timer