Yo guys I want in!! plz.. Anyways my clock might be a little late but here it is.
`This shouldn't matter much, the code should work on any screen size. I hope.
set display mode 640,480,32
sync on
sync rate 60
`Setup vairable for centering the clock and the size of clock
sW = screen width()/2
sH = screen height()/2
sC = screen width()/8
gosub DrawClock
`Getting time info
time$ = get time$()
hour = val(left$(time$,2))
min = val(right$(left$(time$,5),2))
sec = val(right$(time$,2))
if hour = 0 then hour = 24
`Main Loop
do
cls
gosub TimeCheck
paste image 1,sW-sC*1.3,sH-sC*1.3
gosub DrawHands
gosub DrawText
Gosub KeyPress
sync
loop
TimeCheck:
time2$ = get time$()
time$ = right$("0"+str$(hour),2)+":"+right$("0"+str$(min),2)+":"+right$("0"+str$(sec),2)
if time2$<>time3$
sec = sec + 1
if sec >59 then sec = 0 : min = min + 1
if min >59 then min = 0 : hour = hour + 1
if hour > 24 then hour = 0
endif
time3$ = time2$
return
DrawClock:
`Get brown background image for clock
ink rgb(225,180,120),0
dot 0,0
get image 1,0,0,1,1,1
`Setting sprite offscreen and resizing it.
sprite 1, sW*2,sH*2, 1
size sprite 1,sC*2.6,sC*2.6
`pastingthe resized sprite
paste sprite 1, sW-sC*1.3,sH-sC*1.3
ink rgb(255,255,255),0
`drawing the circle multiple times, small to large
for lp = 0 to sC*1.2
circle sW,sH, lp
next lp
ink 0,0
`Drawing the numbers
for lp = 1 to 12
ink rgb(0,0,0),0
set cursor sW+cos((lp-3)*30)*sC-(len(str$(lp))/2)*8, sH+sin((lp-3)*30)*sC-(len(str$(lp))/2)*8
print lp
next lp
ink rgb(0,0,255),0
`Gets the new image
get image 1,sW-sC*1.3,sH-sC*1.3,(sW-sC*1.3)+sC*2.6,(sH-sC*1.3)+sC*2.6,1
return
DrawHands:
`drawing the hour hand in Black
ink rgb(0,0,0),0
line sW, sH, sW+cos((hour-3)*30+(min/2))*sC/1.7, sH+sin((hour-3)*30+(min/2))*sC/1.7
`drawing the min hand also Black
ink rgb(0,0,0),0
line sW, sH, sW+cos((min-15)*6)*sC, sH+sin((min-15)*6)*sC
`drawing the sec hand in Red
ink rgb(255,0,0),0
line sW, sH, sW+cos((sec-15)*6)*sC, sH+sin((sec-15)*6)*sC
return
DrawText:
`Printing instructions
ink rgb(255,255,255),0
txt$ = "Press up&down to change time, press left&right to change clock hand."
set cursor sW-(len(txt$)/2)*8, sH/2.5
print txt$
`Printing the actual time
ink rgb(255,0,0),0
if val(left$(time2$,2)) < 12 or val(left$(time2$,2)) > 23 then ampm$ = "am" else ampm$ = "pm"
set cursor sW-(len(time$)/2)*8, sH*1.5
print time2$," ",ampm$," Actual Time"
`Printing the modifing time
set cursor sW-(len(time$)/2)*8, sH*1.7
if hour > 12 then hour2 = hour - 12 else hour2 = hour
if hour < 12 or hour > 23 then ampm$ = "am" else ampm$ = "pm"
`Printing the hour, if it's selected it'll blink, if not it'll be red.
if tmod = 2 then gosub Blink else ink rgb(255,0,0),0
print right$("0"+str$(hour2),2),":";
`same - tmod is the time modifier.
if tmod = 1 then gosub Blink else ink rgb(255,0,0),0
print right$("0"+str$(min),2),":";
`same
if tmod = 0 then gosub Blink else ink rgb(255,0,0),0
print right$("0"+str$(sec),2);
`finnish printing the am/pm
ink rgb(255,0,0),0
print " ",ampm$
return
KeyPress:
`if up is pressed increase the time depends on which tmod it's on.
if upkey() = 1
if tmod = 0 then sec = sec + 1
if tmod = 1 then min = min + 1
if tmod = 2 then hour = hour + 1
if sec >59 then sec = 0 : min = min + 1
if min >59 then min = 0 : hour = hour + 1
if hour > 24 then hour = 1
endif
`Modifies the tmod varable, changing it from sec>min>hour
if leftkey() = 1
`lockdown the key so tmod only increase once until releasing the key.
if KeyL = 0
tmod = tmod + 1
if tmod > 2 then tmod = 2
endif
`Triggers the lockdown until it resets.
KeyL = 1
else
`Resets if Leftkey isn't pressed.
KeyL = 0
endif
`Modifies the tmod varable, changing it from hour>min>sec
if rightkey() = 1
if KeyR = 0
tmod = tmod - 1
if tmod < 0 then tmod = 0
endif
KeyR = 1
else
keyR = 0
endif
`if up is pressed decrease the time depends on which tmod it's on.
if downkey() = 1
if tmod = 0 then sec = sec - 1
if tmod = 1 then min = min - 1
if tmod = 2 then hour = hour - 1
if sec < 0 then sec = 59 : min = min - 1
if min < 0 then min = 59 : hour = hour - 1
if hour < 1 then hour = 24
endif
Return
Blink:
`This sub will increase the ink color from 100 to 255 making it red>white>red>etc.
Bnk = Bnk + 10
if Bnk > 255 then Bnk = 0
ink rgb(255,Bnk,Bnk),0
return
Lol I did this in dbpro and had to run it through dbclasic it works now.