Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Analog Digital Clock Source
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
thoughtful




PostPosted: Tue Oct 28, 2003 8:01 pm   Post subject: Analog Digital Clock Source

Here the code for the analog & digital clock posted in the submission. I thought it would be good to give off the code as this is not a project i am going to submit.
code:

/*You can use this clock by putting my name & the name of Compsci.ca in the credits*/

var theDateTime, theTime : string
var hours, mins, sec : int
var hours_txt, mins_txt, sec_txt : string
var clockx, clocky : int
var digital : string
var font : int := Font.New ("serif:20")

setscreen ("title:Thoughtful's Clock")
setscreen ("offscreenonly")
setscreen ("graphics:290;300,nobuttonbar")

clockx := 145
clocky := 155


loop
    theDateTime := Time.Date

    theTime := theDateTime (11 .. *)
    hours := strint (theTime (1 .. 2))
    mins := strint (theTime (4 .. 5))
    sec := strint (theTime (7 .. 8))



   

    drawline (clockx, clocky, round (clockx + (95 * cosd ((360 - (sec * 6)) + 90))), round (clocky + (95 * sind (360 - (sec * 6) + 90))), black)
    drawline (clockx, clocky, round (clockx + (20 * cosd ((360 - (sec * 6)) + 90 + 180))), round (clocky + (20 * sind (360 - (sec * 6) + 90 + 180))), black)

    Draw.ThickLine (clockx, clocky, round (clockx + (80 * cosd ((360 - (mins * 6+sec/10)) + 90))), round (clocky + (80 * sind (360 - (mins * 6+sec/10) + 90))), 3, black)
    Draw.ThickLine (clockx, clocky, round (clockx + (12 * cosd ((360 - (mins * 6+sec/10)) + 90 + 180))), round (clocky + (12 * sind (360 - (mins * 6+sec/10) + 90 + 180))), 3, black)

    Draw.ThickLine (clockx, clocky, round (clockx + (40 * cosd ((360 - ((hours * 30 +mins/2))) + 90))), round (clocky + (40 * sind (360 - (hours * 30 +mins/2) + 90))), 3, black)
    Draw.ThickLine (clockx, clocky, round (clockx + (12 * cosd ((360 - ((hours * 30 +mins/2))) + 90 + 180))), round (clocky + (12 * sind (360 - (hours * 30 +mins/2) + 90 + 180))), 3, black)

    if hours > 11 then
        hours := hours - 12
    else
    end if
    if hours < 10 then
        hours_txt := "0" + intstr (hours)
    else
        hours_txt := intstr (hours)
    end if

    if mins < 10 then
        mins_txt := "0" + intstr (mins)
    else
        mins_txt := intstr (mins)
    end if

    if sec < 10 then
        sec_txt := "0" + intstr (sec)
    else
        sec_txt := intstr (sec)
    end if

    digital := hours_txt + ":" + mins_txt + ":" + sec_txt
   
   
    drawfillbox(100,0,195,18,black)
    Font.Draw (digital, 100, 0, font, white)
    drawoval(clockx,clocky,130,130,black)

    View.Update
    cls
end loop



clock.t
 Description:

Download
 Filename:  clock.t
 Filesize:  2.25 KB
 Downloaded:  460 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Wed Oct 29, 2003 11:06 pm   Post subject: (No subject)

very cool, one of the best clock progames i have seen made in turing. (out the hole 3 that i know of Razz )

have some bits
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
djlenny_3000




PostPosted: Mon Mar 08, 2004 8:57 pm   Post subject: (No subject)

can u guys help me out i keep getting an error on the clock programs i can't even use date and time it says:

left bound of substring exceeds right bound by more than 1

i constantly keep running into this problem HELP ME PLZ!!! Doh!
jonos




PostPosted: Mon Mar 08, 2004 10:19 pm   Post subject: (No subject)

you should probably update your turing, yorus may not have the ability for what thoughtul is using.

anyways, nice prog thoughful, really cool and nice looking.
apomb




PostPosted: Tue Mar 09, 2004 6:12 pm   Post subject: (No subject)

jonos and dj ... you know this thread is like 5 months old eh? any way, nice prog ... if you even look at this again thoughtful Confused
TheFerret




PostPosted: Tue Mar 09, 2004 6:57 pm   Post subject: (No subject)

Very good...

+10 Bits
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: