Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clock (repost and modified)
#4
Klingon Clock

           
click the image to zoom in

Code:
'============================================================
'Klingon Clock
'
'References :
'- The Klingon Language Institute version of the pIqaD script
'  https://en.wikipedia.org/wiki/Klingon_scripts
'============================================================

'set window size
#win32
set window "Klingon Clock", 545, 386
set redraw off

'color definition
black       = [0,0,0]
white       = [255,255,255]
green       = [0,255,0]
darkgreen   = [0,150,0,200]

'font
bigfont = createfont("arial", 20, false, false, false, false)
visible klingonScript = loadimage("assets/kscript.png",13,1)

'background
backImg = loadimage("assets/Kli_piqad.png")

'initial value
j = 0 'counter

'-----------
' MAIN LOOP
'-----------
do
    'background
    draw image backImg,0,0

    'system date and time
    t = datetime() 

    'klingon clock
    for i = 1 to 10 step 4.2
        set color darkgreen
        draw rect 55+30*i,20,120,90,true
        set color green
        draw rect 55+30*i,20,120,90
    next
    convertKlingon(t.hour,90)
    convertKlingon(t.minute,210)
    convertKlingon(t.second,340)         
           
    'human digital clock
    set color white
    set font bigfont
    set caret width()/2,120
    myhour = needZero(t.hour)
    myminute = needZero(t.minute)
    mysecond = needZero(t.second)
    center myhour+":"+myminute+":"+mysecond 
   
    if keydown(KEY_ESCAPE,true) then end
   
    'just simple animation
    set color green
    if j >=80 then
        j = 0
    else
        j = j + 1
    endif
    centerx = width()/4
    centery = 250
    r = 10+j
    a = rad(360*t.second/60 - 90)
    for i = 0 to 11
        draw ellipse centerx+(r-15)*cos(30/180*PI*i),centery+(r-15)*sin(30/180*PI*i),2,2,true
        draw ellipse 2*centerx+(r-15)*cos(30/180*PI*i),centery+(r-15)*sin(30/180*PI*i),2,2,true
        draw ellipse 3*centerx+(r-15)*cos(30/180*PI*i),centery+(r-15)*sin(30/180*PI*i),2,2,true
        draw line centerx, centery, centerx + cos(a)*(centerx*0.3), centery + sin(a)*(centery*0.3)
        draw line 2*centerx, centery, centerx + cos(a)*(centerx*0.3), centery + sin(a)*(centery*0.3)
        draw line 3*centerx, centery, centerx + cos(a)*(centerx*0.3), centery + sin(a)*(centery*0.3)
    next
         
    redraw
    fwait 30
loop

'------------
' FUNCTIONS
'------------
function needZero(myclock)
    if len(myclock) = 1  then
        return "0"+myclock
    else
        return myclock
    endif
endfunc

function convertKlingon(x,i)
    if len(x) = 1 then
       x1 = 0
       x2 = x
    else
       x1 = left(x,1)
       x2 = right(x,1)
    endif   
    draw image klingonScript,10+i,40,x1
    draw image klingonScript,50+i,40,x2   
endfunc


Attached Files
.zip   Klingon Clock.zip (Size: 12.62 KB / Downloads: 1)
Reply


Messages In This Thread
Clock (repost and modified) - by 1micha.elok - Yesterday, 04:12 AM
RE: Clock (repost and modified) - by johnno56 - Yesterday, 04:25 AM
RE: Clock (repost and modified) - by 1micha.elok - Yesterday, 04:30 AM
RE: Clock (repost and modified) - by 1micha.elok - Yesterday, 09:34 AM
RE: Clock (repost and modified) - by johnno56 - Yesterday, 01:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)