News:

Welcome to RetroCoders Community

Main Menu

ron's clock (PBCC)

Started by ron77, Aug 06, 2022, 01:28 AM

Previous topic - Next topic

ron77

hi here is an old PBCC (powerbasic console program) an analog clock on graphic screen

#COMPILE EXE
#DIM ALL

GLOBAL hour, minute, sec, pi AS SINGLE
%True = -1
%False = 0

FUNCTION PBMAIN () AS LONG
    clock()


END FUNCTION


SUB clock
    LOCAL hWin AS DWORD
GRAPHIC WINDOW "mishka's clock", 800, 600, 800, 600 TO hwin
GRAPHIC COLOR RGB(255,255,255),RGB(0,0,0)

hour = VAL(LEFT$(TIME$, 2))
minute = VAL(MID$(TIME$, 4, 2))
sec = VAL(RIGHT$(TIME$, 2))

hour = hour + minute / 60 + sec / 3600
minute = minute + sec / 60

pi = 3.14159265
LOCAL i , j, t, t2 , t1 AS SINGLE, k$

    DO

        GRAPHIC CLEAR
        GRAPHIC PRINT TIME$
        GRAPHIC PRINT "press ESC to exit  "

        GRAPHIC ELLIPSE (120, 40)-(540, 440), RGB(255,255,255)
        GRAPHIC ELLIPSE (105, 25)-(555, 455), RGB(255,255,255)
        FOR j = 0 TO 59
            GRAPHIC LINE (320 + 190 * COS((90 - j * 6) * 2 * pi / 360), 240 - 190 * SIN((90 - j * 6) * 2 * pi / 360))-(320 + 200 * COS((90 - j * 6) * 2 * pi / 360), (240 - 200 * SIN((90 - j * 6) * 2 * pi / 360))), RGB(255,255,255)
        NEXT
        FOR i = 0 TO 11
            GRAPHIC LINE (320 + 205 * COS((90 - i * 30) * 2 * pi / 360), 240 - 205 * SIN((90 - i * 30) * 2 * pi / 360))-(320 + 210 * COS((90 - i * 30) * 2 * pi / 360), (240 - 210 * SIN((90 - i * 30) * 2 * pi / 360))), RGB(255,255,255)
        NEXT

        t = 90 - sec * 6
        t1 = 90 - minute * 6
        t2 = 90 - hour * 30

        GRAPHIC LINE (320, 240)-(320 + 200 * COS(t * 2 * pi / 360), (240 - 200 * SIN(t * 2 * pi / 360))), RGB(255,255,255)
        GRAPHIC LINE (320, 240)-(320 + 180 * COS(t1 * 2 * pi / 360), (240 - 180 * SIN(t1 * 2 * pi / 360))), RGB(255,255,255)
        GRAPHIC LINE (320, 240)-(320 + 120 * COS(t2 * 2 * pi / 360), (240 - 120 * SIN(t2 * 2 * pi / 360))), RGB(255,255,255)
        SLEEP (1000)

        sec = sec + 1
        minute = minute + (1 / 60)
        hour = hour + (1 / 3600)
        k$ = INKEY$
        IF k$ = CHR$(32) THEN EXIT SUB
        IF k$ = CHR$(27) THEN END
    LOOP
END SUB