'===========================================================================
' Subject: BAVARIAN CLOCK                     Date: 06-16-97 (10:39)       
'  Author: Andras Hoeffken                    Code: QB, QBasic, PDS        
'  Origin: FidoNet QUIK_BAS Echo            Packet: DATETIME.ABC
'===========================================================================
'A German idiom says:

'      "In Bavaria, clocks run differently"

'Have fun with the following code, it demonstrates some principles 
'of the DRAW statement:

'BAYUHR.BAS - Bayrische Uhr auf dem PC-Bildschirm

SCREEN 12: CLS

xm = 320: ym = 240                 'Mittelpunkt des Ziffernblatts

FOR x = -200 TO 839 STEP 40        'blaues Rautengitter
  LINE (x, 0)-(x + 200, 479), 1
  LINE (x, 0)-(x - 200, 479), 1
NEXT
FOR y = 1 TO 6                     'bayer. Farben hinein
  ord = y * 95.5 - 48
  FOR x = 24 TO 656 STEP 39.5
    PAINT (x, ord - 48), 15, 1     'weiss
    PAINT (x - 20, ord), 1, 1      'blau
  NEXT x
NEXT y
CIRCLE (xm, ym), 180, 14           'grosser Uhrenkreis, Radius 180 dots
PAINT (xm, ym), 7, 14              'innenfarbe 7 = grau
                                   'Skala:
FOR n = 6 TO 360 STEP 6            '360 Grad, 60 Minuten -> 6ø/min
  wi = (n / 180) * 3.1415926#
  x = xm + SIN(wi) * 180           'Radiuspunkt
  y = ym + COS(wi) * 180
  f = 7: l = 5                     'l/f = kleine Strichlaenge / grau
  IF n MOD 30 = 0 THEN             'bei 5 min Punkten:
    f = 15: l = 14                 '  grosse Strichlaenge / weiss
    s = xm + SIN(wi) * 195         'Printposition
    z = ym - COS(wi) * 180
    LOCATE z \ 14 - 1, s \ 8
    v = 360 - n                    'Winkel rechtsrum -> linksrum
    IF v = 0 THEN v = 360
    PRINT v \ 30;                  'Zahl printen
  END IF
  PSET (x, y), f                   'vom Radiuspunkt aus
  DRAW "ta"+STR$(n)+"u"+STR$(l)    'Strich nach innen ziehen
NEXT n

LOCATE 29,2: PRINT "In Bavaria, clocks run differently";

PSET (xm, ym)
asw$="10":amw$="10":ahw$="10"      '"alte" Werte initialisieren

DO                                 'Zeiger animieren:
  x$ = TIME$
  h = VAL(LEFT$(x$, 2)) MOD 12
  m = VAL(MID$(x$, 4, 2))
  s = VAL(RIGHT$(x$, 2))
  hw$ = STR$(INT(h * 30 + m * .5)) 'h Wert
  mw$ = STR$(INT(m * 6 + s * .1))  'm Wert
  sw$ = STR$(s * 6)                's Wert
  IF asw$ <> sw$ THEN
    DRAW "c7ta" + ahw$ + "nu130"   'alter Stundenzeiger weg
    DRAW "c7ta" + amw$ + "nu162"   '  "   Minuten  "     "
    DRAW "c7ta" + asw$ + "nu162"   '  "   Sekunden "     "
    DRAW "c0ta" + hw$ + "nu130"    'neue Stunden / Minuten = schwarz
    DRAW "c0ta" + mw$ + "nu162"
    DRAW "c14ta" + sw$ + "nu162"   'neue Sekunden = gelb
    asw$=sw$:amw$=mw$:ahw$=hw$     'alte Werte merken
  END IF
  A$ = INKEY$
LOOP UNTIL A$ <> ""                'Tastendruck = Ende
SCREEN 0
CLS
END
