'This is my first analog clock!
'Thank you to someone named Chris Procter who put a QBasic clock online around 20 years ago or so.
'I used some of his math to make this clock.
'This clock was updated and simplified a lot using the QB64 _DELAY command.
'This was made by Ken G. and is freeware.
PRINT " Analog Alarm Clock" PRINT " To set alarm, start clock and then press 'A' to set." PRINT " Hours must be set to a 24 hour scale (0-23)." PRINT " The clock will chime the hours every hour on top of the hour." PRINT " To shut off clock, press 'Q' or click the X button on the upper right corner." PRINT " Press any key to start clock.", gggo:
drawing:
go:
hourset:
INPUT "Hour (24 Hour Format 0-23): ", hr
minuteset:
secondset:
set = 1
ss = (60 - sc) * 6 + 180
x2
= INT(SIN(ss
/ 180 * 3.141592) * 180) + 5 y2
= INT(COS(ss
/ 180 * 3.141592) * 180) + 5 x2 = x2 + 323
y2 = y2 + 220
minutes
= TIMER \
60 - hours
* 60seconds
= (TIMER - hours
* 3600 - minutes
* 60)'Check For Alarm
sounds:
alarm = alarm + 50
IF alarm
= 800 THEN alarm
= 100 clr
= clr
+ 1:
IF clr
= 15 THEN clr
= 1 LOCATE 1, 20:
PRINT "ALARM IS GOING OFF! - Press Space Bar to stop." set = 0
alarm = 0: clr = 0: hr = 0: mn = 0: se = 0
a$ = "": al$ = ""
'Seconds
s = (60 - seconds) * 6 + 180
LINE (325, 225)-(x
, y
), 0 x
= INT(SIN(s
/ 180 * 3.141592) * 180) + 325y
= INT(COS(s
/ 180 * 3.141592) * 180) + 225LINE (325, 225)-(x
, y
), 15 'Minutes
m = 180 - minutes * 6
LINE (325, 225)-(xx
, yy
), 0 xx
= INT(SIN(m
/ 180 * 3.141592) * 180) + 325yy
= INT(COS(m
/ 180 * 3.141592) * 180) + 225LINE (325, 225)-(xx
, yy
), 15 'Hours
h = 360 - hours * 30 + 180
LINE (325, 225)-(xxx
, yyy
), 0 xxx
= INT(SIN(h
/ 180 * 3.141592) * 100) + 325yyy
= INT(COS(h
/ 180 * 3.141592) * 100) + 225LINE (325, 225)-(xxx
, yyy
), 15 'Chimes
hour2 = hou
IF hour2
> 12 THEN hour2
= hour2
- 12 ttt = 0
'queue some sound
sample
= SIN(ttt
* 340 * ATN(1) * 8) '340Hz sine wave (ttt * 440 * 2p) sample
= sample
* EXP(-ttt
* 3) 'fade out eliminates clicks after sound ttt
= ttt
+ 1 / _SNDRATE 'sound card sample frequency determines time 'do other stuff, but it may interrupt sound