'+---------------+---------------------------------------------------+
'| ###### ###### | .--. . .-. |
'| ## ## ## # | | )| ( ) o |
'| ## ## ## | |--' |--. .-. `-. . .-...--.--. .-. |
'| ###### ## | | \ | |( )( ) | ( || | |( ) |
'| ## ## | ' `' `-`-' `-'-' `-`-`|' ' `-`-'`- |
'| ## ## # | ._.' |
'| ## ###### | Sources & Documents placed in the Public Domain. |
'+---------------+---------------------------------------------------+
'| |
'| === BinClock.bas === |
'| |
'| == A simple binary (BCD) clock inspired by the alien countdown |
'| == from the movie "Mission to Mars". |
'| |
'+-------------------------------------------------------------------+
'| Done by RhoSigma, R.Heyder, provided AS IS, use at your own risk. |
'| Find me in the QB64 Forum or mail to support&rhosigma-cw.net for |
'| any questions or suggestions. Thanx for your interest in my work. |
'+-------------------------------------------------------------------+
'setup screen
scrFont&
= _LOADFONT("C:\Windows\Fonts\timesbd.ttf", 72)
'3D space origin is on these screen coordinates
'init BCD discs
InitDiscs
'draw hour/minute/seconds separators
Line3D 175, 0, 0, 175, 440, 0, 2
Line3D 175, 0, 0, 175, 0, -110, 2
Line3D 425, 0, 0, 425, 440, 0, 2
Line3D 425, 0, 0, 425, 0, -110, 2
'main loop
FlipDiscs
'run the clock
newState&
= (VAL(MID$(t$
, 1, 1)) * (2 ^ 20)) + (VAL(MID$(t$
, 2, 1)) * (2 ^ 16)) +_
diff&
= curState&
XOR newState&
curState& = newState&
IF (n%
MOD 4) = 0 THEN AxisSegments Discs
(n%
).x
Circle3D Discs(n%).x, Discs(n%).y, Discs(n%).z, Discs(n%).r, Discs(n%).a, 0
Circle3D Discs(n%).x, Discs(n%).y, Discs(n%).z, Discs(n%).r, Discs(n%).a + 1, 15
Discs(n%).a = Discs(n%).a + 1
IF Discs
(n%
).a
= 180 THEN Discs
(n%
).a
= 0 Circle3D Discs(n%).x, Discs(n%).y, Discs(n%).z, Discs(n%).r, Discs(n%).a, 15
'setup start values for all discs
n% = 0
Discs(n%).x = i%
Discs(n%).y = j%
Discs(n%).z = 0
Discs(n%).r = 30
Discs(n%).a = 0
n% = n% + 1
Discs(n%).x = i%
Discs(n%).y = j%
Discs(n%).z = 0
Discs(n%).r = 30
Discs(n%).a = 0
n% = n% + 1
Discs(n%).x = i%
Discs(n%).y = j%
Discs(n%).z = 0
Discs(n%).r = 30
Discs(n%).a = 0
n% = n% + 1
'draw rotation axis segments between discs
Line3D x%, 0, 0, x%, 40, 0, 4
Line3D x%, 100, 0, x%, 140, 0, 4
Line3D x%, 200, 0, x%, 240, 0, 4
Line3D x%, 300, 0, x%, 340, 0, 4
Line3D x%, 400, 0, x%, 440, 0, 4
SUB Line3D
(x1%
, y1%
, z1%
, x2%
, y2%
, z2%
, col%
) 'x1%/y1%/z1% = start, x2%/y2%/z2% = end, col% = color pen
x1# = (x1% + (y1% * 0.5)): z1# = (z1% + (y1% * 0.5))
x2# = (x2% + (y2% * 0.5)): z2# = (z2% + (y2% * 0.5))
LINE (x1#
+ cx%
- 1, -z1#
+ cy%
)-(x2#
+ cx%
- 1, -z2#
+ cy%
), col%
LINE (x1#
+ cx%
, -z1#
+ cy%
)-(x2#
+ cx%
, -z2#
+ cy%
), col%
LINE (x1#
+ cx%
+ 1, -z1#
+ cy%
)-(x2#
+ cx%
+ 1, -z2#
+ cy%
), col%
SUB Circle3D
(x%
, y%
, z%
, r%
, ba%
, col%
) 'x%/y%/z% = center, r% = radius, ba% = B-Axis angle, col% = color pen
mx# = (x% + (y% * 0.5)): mz# = (z% + (y% * 0.5))
zx#
= r%
* COS(ba%
* 0.01745329)zz#
= r%
* SIN(ba%
* 0.01745329) x#
= zx#
* COS(cir%
* 0.01745329) y#
= r%
* SIN(cir%
* 0.01745329) z#
= zz#
* COS(cir%
* 0.01745329) x# = (x# + (y# * 0.5)): z# = (z# + (y# * 0.5))
LINE (x#
+ mx#
+ cx%
- 1, -z#
+ -mz#
+ cy%
- 1)-(x#
+ mx#
+ cx%
+ 1, -z#
+ -mz#
+ cy%
+ 1), col%
, BF