remstart ------------------------------------------------------------------- program name: matrix clock ------------------------------------------------------------------- written by: latch date: 18-01-2007 ------------------------------------------------------------------- comments: clock using matrix point heights ------------------------------------------------------------------- remend set display mode 800,600,32 autocam off sync on sync rate 60 hide mouse rem ============================================================= rem = Array to hold number data rem ============================================================= tilex=69 tilez=18 dim number(9,tilez,tilex) for n = 0 to 9 for z = 0 to tilez for x = 0 to 8 read number(n,z,x) next x next z next n rem ============================================================= rem = CREATE MATRIX rem ============================================================= make matrix 1,tilex,tilez,tilex,tilez rem add colons for z = 0 to tilez for x = 0 to 1 read y set matrix height 1,x+46,z,y*3 set matrix height 1,x+22,z,y*3 next x next z `SET MATRIX Matrix Number, Wireframe, Transparency, Cull, Filter, Light, Fog, Ambient set matrix 1,1,1,1,1,1,1,0 update matrix 1 rem ============================================================= rem = MAKE CASE TO HOLD CLOCK rem ============================================================= make object box 1,69,6,18 color object 1,rgb(0,10,255) ghost object on 1 position object 1,34.5,3,9 position camera tilex/2,50,-10 xrotate camera 75 rem ============================================================= rem = MAIN LOOP rem ============================================================= gosub _lighting color backdrop 0 do gosub _time_pos gosub _move_spot rem move camera left and right camx#=camera position x() if leftkey()=1 then camx#=camera position x()-.5 if rightkey()=1 then camx#=camera position x()+.5 position camera camx#,camera position y(),camera position z() rem info text 0,0,"Move camera left + right with arrow keys" sync loop end rem ============================================================= rem = SUB-ROUTINES rem ============================================================= _time_pos: height=5 a$=get time$() sizet=len(a$) rem get seconds sec1=val(mid$(a$,sizet)) sec2=val(mid$(a$,sizet-1)) rem get minutes min1=val(mid$(a$,sizet-3)) min2=val(mid$(a$,sizet-4)) rem get hours hour1=val(mid$(a$,sizet-6)) hour2=val(mid$(a$,sizet-7)) for z = 0 to tilez for x = 0 to 8 set matrix height 1,x+60,z,number(sec1,z,x)*height set matrix height 1,x+49,z,number(sec2,z,x)*height set matrix height 1,x+36,z,number(min1,z,x)*height set matrix height 1,x+25,z,number(min2,z,x)*height set matrix height 1,x+12,z,number(hour1,z,x)*height set matrix height 1,x+1,z,number(hour2,z,x)*height next x next z gosub _smooth_matrix update matrix 1 return `------------------------------------------------------------------------ _smooth_matrix: rem from DarkBASIC example code rem Author : DBS-LB rem Date : 19th July 2000 rem Use matrix normals to make it smooth for z=1 to tilez for x=1 to tilex rem Get matrix heights h8#=get matrix height(1,x,z-1) h4#=get matrix height(1,x-1,z) h#=get matrix height(1,x,z) h2#=get matrix height(1,x,z) rem Calculate projected angle X using heights x1#=(x-1)*25.0 : y1#=h# x2#=(x+0)*25.0 : y2#=h4# dx#=x2#-x1# dy#=y2#-y1# ax#=atanfull(dx#,dy#) ax#=wrapvalue(90-ax#) rem Calculate projected angle Z using heights z1#=(z-1)*25.0 : y1#=h2# z2#=(z+0)*25.0 : y2#=h8# dz#=z2#-z1# dy#=y2#-y1# az#=atanfull(dz#,dy#) az#=wrapvalue(90-az#) rem Make normal from projected angle nx#=sin(ax#) ny#=cos(ax#) nz#=sin(az#) rem Setting matrix normal for smoothness set matrix normal 1,x,z,nx#,ny#,nz# next x next z return `------------------------------------------------------------------------ _lighting: make light 1 make light 2 make light 3 set point light 0,-30,5,10 color light 0,rgb(0,0,255) set point light 1,100,5,10 color light 1,rgb(0,0,255) set point light 2,34.5,8,20 color light 2,rgb(0,0,255) set spot light 3,5,15 color light 3,rgb(0,200,100) position light 3,35,60,0 point light 3,tilex/2,0,tilez/2 set ambient light 0 return `------------------------------------------------------------------------- _move_spot: ang#=wrapvalue(ang#+.5) rotate light 3,ang#,ang#,0 return rem ============================================================= rem = DATA STATEMENTS rem ============================================================= rem 0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,1,1,1,1,1,1,1,0 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,0,0,0,0,0,1,1 data 1,1,0,0,0,0,0,1,1 data 1,1,0,0,0,0,0,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 0,1,1,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 1 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,0,1,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 2 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,1,1,1,1,0,0 data 0,0,1,1,1,1,1,1,0 data 0,1,1,1,1,1,1,0,0 data 1,1,1,0,0,0,0,0,0 data 1,1,1,0,0,0,0,0,0 data 1,1,1,0,0,0,0,0,0 data 0,1,1,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,1,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,1,1,1,1,1,1,0 data 0,1,1,1,1,1,1,0,0 data 0,0,1,1,1,1,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 3 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,1,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,1,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 4 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,1,1,1,1,1,1 data 0,0,1,1,1,1,1,1,1 data 0,1,1,1,1,1,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 0,1,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,0,1,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 5 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,1,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,1,1,1,1,1,0,0,0 data 1,1,1,0,0,0,0,0,0 data 1,1,1,0,0,0,0,0,0 data 1,1,1,0,0,0,0,0,0 data 0,1,1,1,1,1,1,0,0 data 0,0,1,1,1,1,1,1,0 data 0,0,0,1,1,1,1,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 6 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,1,1,1,1,1,1,1,0 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,1,1,1,1,1,0 data 1,1,1,1,1,1,1,0,0 data 1,1,1,1,1,1,0,0,0 data 1,1,1,0,0,0,0,0,0 data 1,1,1,0,0,0,0,0,0 data 1,1,1,0,0,0,0,0,0 data 0,1,1,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 7 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,1,0,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 0,1,1,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 8 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,1,1,1,1,1,1,1,0 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 0,1,1,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,1,1,1,1,1,1,1,0 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 0,1,1,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem 9 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,1,1,0 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,0,0,0,1,1,1 data 0,0,0,1,1,1,1,1,1 data 0,0,1,1,1,1,1,1,1 data 0,1,0,1,1,1,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 1,1,1,0,0,0,1,1,1 data 0,1,1,1,1,1,1,1,0 data 0,0,1,1,1,1,1,0,0 data 0,0,0,1,1,1,0,0,0 data 0,0,0,0,0,0,0,0,0 data 0,0,0,0,0,0,0,0,0 rem colon data 0,0 data 0,0 data 0,0 data 0,0 data 0,0 data 0,0 data 1,1 data 1,1 data 0,0 data 0,0 data 0,0 data 1,1 data 1,1 data 0,0 data 0,0 data 0,0 data 0,0 data 0,0 data 0,0