// Project: Clock
// Created: 22-01-17
// by Andrew van Dijk
// show all errors
// Usefull for using cos and sin to determine a point on a circle
// General term
// x = radius * cos(angle)
// y = radius * sin(angle)
SetErrorMode(2)
// set window properties
SetWindowTitle( "Clock" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
SetVirtualResolution(100,100)
SetDisplayAspect(1.333333)
x1# = 50 //Center of screen
y1# = 50 //Center of screen
radius# = 20 // radius from center of circle to outside
do
for i = 0 to 359 step 30
angle# = i
outerx# = x1# + radius# * cos(angle#)
outery# = y1# + radius# * sin(angle#) * 1.333333
midx# = x1# + (radius#-1) * cos(angle#)
midy# = y1# + (radius#-1) * sin(angle#) * 1.333333
DrawLine( midx#, midy#, outerx# , outery# , mod (i,255), mod (i,255), 255 )
next i
time = GetUnixTime()
second = GetSecondsFromUnix( time )
x0# = x1# + (radius#-1) * cos((-90)+(6 *second))
y0# = y1# + (radius#-1) * sin((-90)+(6 *second)) * 1.333333
DrawLine( x1#, y1#, x0# , y0# , mod (i,255), mod (i,255), 255 )
DrawEllipse(x0# ,y0# , 1,1 * 1.333333, MakeColor(255,64,mod (second,255),255) ,MakeColor(255,64,mod (second,255),255) ,1)
minute = GetMinutesFromUnix( time )
x0# = x1# + (radius#-3) * cos((-90)+(6 * minute))
y0# = y1# + (radius#-3) * sin((-90)+(6 * minute)) * 1.333333
DrawLine( x1#, y1#, x0# , y0# , mod (i,255), mod (i,255), 255 )
hour = GetHoursFromUnix( time ) + 2
x0# = x1# + (radius#-6) * cos((-90)+(6 * 5 * hour))
y0# = y1# + (radius#-6) * sin((-90)+(6 * 5* hour)) * 1.333333
DrawLine( x1#, y1#, x0# , y0# , mod (i,255), mod (i,255), 255 )
Sync()
loop
Setvirtualresolution(640,480) Repeat For x=0 to 360 result#=Cos(x)*100 Drawline(x,200,x,200-result#,255,255,255) Next i Sync() Until Timer()>15 End