ZX BASIC:Clock.Bas

From BorielWiki
Jump to: navigation, search
Program: clock.bas
  1. REM From the ZX Spectrum MANUAL
  2. REM A Clock program
  3.  
  4. REM First we draw the Sphere
  5. CLS
  6. FOR n = 1 TO 12
  7. PRINT AT 10 - (10 * COS(n * PI / 6) - 0.5), 16 + (0.5 + 10 * SIN(n * PI / 6)); n
  8. NEXT n
  9. PRINT AT 23, 0; "PRESS ANY KEY TO EXIT";
  10.  
  11. FUNCTION t AS ULONG
  12. REM Reads the FRAMES counter
  13. RETURN INT((65536 * PEEK(23674) + 256 * PEEK(23673) + PEEK(23672))/50)
  14. END FUNCTION
  15.  
  16. DIM t1 AS FLOAT
  17.  
  18. OVER 1
  19. WHILE INKEY$ = ""
  20. LET t1 = t()
  21. LET a = t1 / 30 * PI: REM a is the seconds pointer in radians
  22. LET sx = 72 * SIN a : LET sy = 72 * COS a
  23. PLOT 131, 107: DRAW sx, sy
  24.  
  25. LET t2 = t()
  26. WHILE (t2 <= t1) AND (INKEY$ = "")
  27. REM WARNING: Empty loops might be optimized and removed
  28. LET t2 = t()
  29. END WHILE : REM Wait until the moment to move it
  30.  
  31. PLOT 131, 107: DRAW sx, sy
  32. END WHILE
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox
Translate
Google AdSense