I've decided to code an analog clock using a portion of code I found on https://qb64sourcecode.com/:

https://qb64sourcecode.com/task12code2.png

Everything is going fine but one : the hour hand.

It moves one time on each new hour and I'd like to make it move as time passes by.

I've tried differents values, but so far, I didn't succeed.

Here is my code:

Code: Select all

```
'Horloge analogique
_TITLE "Horloge analogique vintage"
SCREEN _NEWIMAGE(640, 320, 32)
Blanc& = _RGB32(255, 255, 255)
Jaune& = _RGB32(255, 255, 0)
Cyan& = _RGB32(64, 224, 208)
Vert& = _RGB32(0, 255, 0)
Rouge& = _RGB32(255, 0, 0)
Noir& = _RGB32(0, 0, 0)
Gris& = _RGB32(63, 63, 63)
Pi2! = 8 * ATN(1)
sec! = Pi2! / 60
min! = Pi2! / 60
heure! = Pi2! / 60
arc! = Pi2! / 12
arc2! = Pi2! / 60
FOR t! = 0 TO Pi2! STEP arc!
cx% = CINT(COS(t!) * 70)
cy% = CINT(SIN(t!) * 70)
CIRCLE (cx% + 320, cy% + 160), 1, Vert&
CIRCLE (cx% + 320, cy% + 160), 2, Vert&
NEXT t!
DO
_LIMIT 1000
CIRCLE (320, 160), 1, Blanc&
CIRCLE (320, 160), 2, Blanc&
CIRCLE (320, 160), 3, Blanc&
Year% = VAL(RIGHT$(DATE$, 4))
Jour% = VAL(RIGHT$(DATE$, 7))
Mois% = VAL(RIGHT$(DATE$, 11))
LOCATE 2, 28
COLOR Cyan&
mois$ = LEFT$(DATE$, 2)
M = VAL(mois$)
SELECT CASE M
CASE 1: Lune$ = "janvier"
CASE 2: Lune$ = "février"
CASE 3: Lune$ = "mars"
CASE 4: Lune$ = "avril"
CASE 5: Lune$ = "mai"
CASE 6: Lune$ = "juin"
CASE 7: Lune$ = "juillet"
CASE 8: Lune$ = "août"
CASE 9: Lune$ = "septembre"
CASE 10: Lune$ = "octobre"
CASE 11: Lune$ = "novembre"
CASE 12: Lune$ = "décembre"
END SELECT
Longueur = LEN(Lune$) + 17
LOCATE 2, (80 - Longueur - 3)
PRINT Jour%; Lune$; Year%; "| "; TIME$
Seconds% = VAL(RIGHT$(TIME$, 2)) - 15
S! = sec! * Seconds%
Minutes% = VAL(RIGHT$(TIME$, 5)) - 15
M! = min! * Minutes%
Heure% = VAL(RIGHT$(TIME$, 8)) - 15
H! = (heure! * 5) * Heure%
IF Heure% >= 13 OR Heure% <= 24 THEN Heure% = Heure% - 12
IF VAL(RIGHT$(TIME$, 5)) >= 12 THEN
_LIMIT 1000
H! = H! + 0.016
END IF
IF VAL(RIGHT$(TIME$, 5)) >= 24 THEN
_LIMIT 1000
H! = H! + 0.033
END IF
IF VAL(RIGHT$(TIME$, 5)) >= 36 THEN
_LIMIT 1000
H! = H! + 0.05
END IF
IF VAL(RIGHT$(TIME$, 5)) >= 48 THEN
_LIMIT 1000
H! = H! + 0.067
END IF
IF VAL(RIGHT$(TIME$, 5)) = 0 AND VAL(RIGHT$(TIME$, 2)) = 0 THEN
_LIMIT 1000
BEEP
END IF
Sx% = CINT(COS(S!) * 50)
Sy% = CINT(SIN(S!) * 50)
Mx% = CINT(COS(M!) * 60)
My% = CINT(SIN(M!) * 60)
Hx% = CINT(COS(H!) * 45)
Hy% = CINT(SIN(H!) * 45)
LINE (320, 160)-(Sx% + 320, Sy% + 160), Rouge&
LINE (320, 160)-(Mx% + 320, My% + 160), Jaune&
LINE (320, 160)-(Hx% + 320, Hy% + 160), Jaune&
DO
_LIMIT 1000
Verif% = VAL(RIGHT$(TIME$, 2)) - 15
Verif1% = VAL(RIGHT$(TIME$, 5)) - 15
Verif2% = VAL(RIGHT$(TIME$, 8)) - 15
LOOP UNTIL Verif% <> Seconds% OR Verif1% <> Minutes% OR Verif2% <> Heure%
_DISPLAY
LINE (320, 160)-(Sx% + 320, Sy% + 160), Noir&
LINE (320, 160)-(Mx% + 320, My% + 160), Noir&
LINE (320, 160)-(Hx% + 320, Hy% + 160), Noir&
LOCATE 18, 45
COLOR Jaune&
PRINT "Clic gauche ou <"; CHR$(144); "chap> pour quitter"
Mouse = _MOUSEINPUT
K$ = INKEY$
IF K$ = CHR$(27) OR _MOUSEBUTTON(1) THEN SYSTEM
LOOP UNTIL INKEY$ = CHR$(27)
```

Code: Select all

```
IF VAL(RIGHT$(TIME$, 5)) >= 12 THEN
_LIMIT 1000
H! = H! + 0.016
END IF
IF VAL(RIGHT$(TIME$, 5)) >= 24 THEN
_LIMIT 1000
H! = H! + 0.033
END IF
IF VAL(RIGHT$(TIME$, 5)) >= 36 THEN
_LIMIT 1000
H! = H! + 0.05
END IF
IF VAL(RIGHT$(TIME$, 5)) >= 48 THEN
_LIMIT 1000
H! = H! + 0.067
END IF
```

Do you have an idea?

Thanks,

W.