Author Topic: Simulation of a clock made in Quebec  (Read 3679 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Simulation of a clock made in Quebec
« on: February 01, 2019, 11:46:27 am »
Code: QB64: [Select]
  1. DEFINT A-Z
  2. DIM xo(3), x(3, 60), y(3, 60), k(3, 60)
  3. xm = 639: xc = xm \ 2: xs = 180
  4. ym = 479: yc = ym \ 2: ys = 240
  5. q! = .67: xo(1) = xc - xs * q!: xo(2) = xc: xo(3) = xc + xs * q!
  6. red = 4: yellow = 14: green = 10: z = 3
  7. FOR c = 1 TO 3
  8.     FOR a = 0 TO 59
  9.         r! = ((a * 6) - 90) * ATN(1) / 45
  10.         x(c, a) = xo(c) + (xs - 8) * COS(r!)
  11.         y(c, a) = yc + (ys - 8) * SIN(r!)
  12.         IF c = 2 THEN k = yellow ELSE k = red
  13.         d = VAL(MID$("051015", (c - 1) * 2 + 1, 2))
  14.         IF (a MOD d) = 0 THEN k = green
  15.         k(c, a) = k
  16.     NEXT a
  17.     t$ = TIME$
  18.     h = VAL(MID$(t$, 1, 2)): h = h + (h > 12) * 12
  19.     m = VAL(MID$(t$, 4, 2))
  20.     s = VAL(MID$(t$, 7, 2))
  21.     FOR c = 1 TO 3
  22.         IF c = 1 THEN t = h * 5 + m / 10
  23.         IF c = 2 THEN t = m
  24.         IF c = 3 THEN t = s
  25.         FOR a = 0 TO 59
  26.             IF a <= t THEN k = k(c, a) ELSE k = 0
  27.             IF k <> POINT(x(c, a), y(c, a)) THEN
  28.                 CIRCLE (x(c, a), y(c, a)), z, 7
  29.                 PAINT (x(c, a), y(c, a)), 0, 7
  30.                 CIRCLE (x(c, a), y(c, a)), z, k
  31.                 PAINT (x(c, a), y(c, a)), k, k
  32.             END IF
  33.         NEXT a
  34.     NEXT c
  35.     DO: _LIMIT 10
  36.         i$ = INKEY$
  37.         IF i$ = "c" THEN CLS
  38.         IF i$ = CHR$(27) THEN END
  39.     LOOP UNTIL t$ <> TIME$
It works better if you plug it in.