Hi, while learning DB Pro i made a little analog clock program with the basic 2d commands.
Rem Project: Analog Clock
Rem Created: Monday, January 19, 2015
Rem ***** Main Source File *****
set display mode 320,240,32
set window on
set window title "DarkBasic Pro Clock"
`Define Mid of Screen
sx = screen width() / 2
sy = screen height() / 2
`Lenght of Pointer
lenght = 50
`Get The Current System Time
currentTime$ = get time$()
currentSec = val(right$(currentTime$,2))
currentMin = val((mid$(currentTime$,4)) + (mid$(currentTime$,5)))
currentHour = val(left$(currentTime$,2))
if currentHour > 12 Then dec currentHour,12
`Starting Angles Of Sec, Min & Hour Pointers
startAngle = wrapvalue(270 + currentSec * (360 / 60))
mstartAngle = wrapvalue(270 + currentMin * (360 / 60))
hstartAngle = wrapvalue(270 + currentHour * (360 / 12))
`Variables For Hold The Degree Changes Of Sec, Min & Hour
degree# = 0
mdegree# = 0
hdegree# = 0
`Draw Border Of Clock
ink rgb(0,255,255),0
circle sx,sy, lenght + 5
circle sx,sy, lenght + 7
for i = 0 to 59
angle# = wrapvalue(degree# + 270)
ex = cos(angle#) * (lenght + 3)
ey = sin(angle#) * (lenght + 3)
if i = 0 OR i = 15 OR i = 30 OR i = 45
ink rgb(255,0,0),0
circle ex + sx, ey + sy, 2
else
ink rgb(255,255,0),0
dot ex + sx, ey + sy
endif
inc degree#,6
next
center text sx,sy - (lenght + 30), "DarkBasic Pro"
center text sx,sy + (lenght + 20), "It's Time"
`Main Loop
do
`Draw Hour Pointer
ink rgb(0,0,255),0
angle# = wrapvalue(hdegree# + hstartAngle)
hex = cos(angle#) * (lenght - 15)
hey = sin(angle#) * (lenght - 15)
line sx,sy,hex + sx,hey + sy
`Draw Min Pointer
ink rgb(0,255,0),0
angle# = wrapvalue(mdegree# + mstartAngle)
mex = cos(angle#) * (lenght - 5)
mey = sin(angle#) * (lenght - 5)
line sx,sy,mex + sx,mey + sy
`Draw Sec Pointer
ink rgb(255,0,0),0
angle# = wrapvalue(degree# + startAngle)
ex = cos(angle#) * lenght
ey = sin(angle#) * lenght
line sx,sy,ex + sx,ey + sy
circle sx,sy, 3
`Wait For 1 Sec
wait 1000
`delete sec pointer
ink rgb(0,0,0),0
line sx,sy,ex + sx,ey + sy
inc degree#,6
`Update Min Pointer
if wrapvalue(degree# + startAngle) = 270
inc mdegree#,6
line sx,sy,mex + sx,mey + sy
endif
`Update Hour Pointer
if wrapvalue(degree# + startAngle) = 270 AND wrapvalue(mdegree# + startAngle) = 270
inc hdegree#,30
line sx,sy,hex + sx,hey + sy
endif
loop
`End Program
wait key
end
Back to the Basic Roots - Dark Power Inside