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

Username:   Password: 
 RegisterRegister   
 Screensaver with time across the screen
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xmen




PostPosted: Mon Mar 29, 2004 10:40 pm   Post subject: Screensaver with time across the screen

yea so my question is how do i make a screensaver with time across the screen keep on movin to left n back out from rite again?

i kno turing can actually read the time of the day......but i just duno how to put it across the screen

if the time thing doesnt work, i kno how to read n get from a text file.....so whatever i type on the first line on that text file will be shown across the screen like the time.......

DOES ANYONE KNOW HOW TO DO THIS??????????
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Mon Mar 29, 2004 10:59 pm   Post subject: (No subject)

well you can take a look at thoughtfull's clock program, see if it helps you:
http://www.compsci.ca/v2/viewtopic.php?t=2133
Tony




PostPosted: Mon Mar 29, 2004 11:04 pm   Post subject: (No subject)

Eh... you'd want to use Font.Draw for that

code:

View.Set ("offscreenonly")
var fontID : int := Font.New ("Arial:20")
colorback (black)
loop
    for i : (Font.Width ("Tony", fontID) * -1) .. (maxx + Font.Width ("Tony", fontID)) by 10
        Font.Draw ("Tony", i, 100, fontID, green)
        View.Update
        cls
    end for
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
xmen




PostPosted: Mon Mar 29, 2004 11:33 pm   Post subject: (No subject)

thnx tony

but i combine with some stuff with urs to actually make the program exactly i wanted with actually time (with moving seconds)

if anyone wants it its here:

code:

View.Set ("offscreenonly,graphics:800;600")
var fontID : int := Font.New ("Arial:60:bold")
colorback (black)

var timeofday : string
time (timeofday)
loop
    for i : (Font.Width (timeofday, fontID) * -1) .. (maxx + Font.Width (timeofday, fontID))
        time (timeofday)
        Font.Draw (timeofday, i, maxy div 2, fontID, yellow)
        View.Update
        cls
        delay (1)
        exit when hasch
    end for
end loop
xmen




PostPosted: Mon Mar 29, 2004 11:44 pm   Post subject: (No subject)

lol ok im quite picky here but.......noticing that the time in my program is 24hrclock.......does anyone kno how i can change that to 12hrclock?? how bout with am/pm at the back??

anyone who knows plzzzz share with us. Thankyou.
Tony




PostPosted: Tue Mar 30, 2004 12:33 am   Post subject: (No subject)

well its a string, so grab your first two characters, convert them to numbers (strint) and take a look if its above 12 or not. If so, its PM and you subtracks 12 and stick it back in, otherwise you leave it as it is and its AM
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
xmen




PostPosted: Tue Mar 30, 2004 4:25 pm   Post subject: (No subject)

sry but i cant reli get the strint part to work.....can ya plz show me??
xmen




PostPosted: Tue Mar 30, 2004 4:48 pm   Post subject: (No subject)

i get error for this
code:

var timeofday : string
var x1 : int
time (timeofday)
x1 := strint (timeofday)

put x1

why???
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Tue Mar 30, 2004 5:11 pm   Post subject: (No subject)

because a colon (Smile is not an integer. If you get rid of that bit about x1 and just type "put timeofday" then the prog will output the time of day when you ran the prog. That time of day is in this format "HH:MM:SS" . it contains colons, which cannot be converted into integers.
xmen




PostPosted: Tue Mar 30, 2004 5:22 pm   Post subject: (No subject)

ok i just want the program to display the hour in 12 hr clock format, NOT 24hr clock

can someone just simply modify my screensaver program for me?? i just dont get it man
xmen




PostPosted: Tue Mar 30, 2004 5:34 pm   Post subject: (No subject)

ok nvm guys.....its all done

its here if ya wanna see it...
code:

View.Set ("offscreenonly,graphics:800;600")
var fontID : int := Font.New ("Arial:60:bold")
colourback (grey)

var timeofday, t1, t2, ttt : string
var am : string := "AM"
var pm : string := "PM"
var timeofday1, t11 : int
time (timeofday)
const len := length (timeofday)
t1 := timeofday (1) + timeofday (2)
t11 := strint (t1)
t2 := timeofday (3 .. 8)
if t11 > 12 then
    timeofday1 := (t11 - 12)
    ttt := intstr (timeofday1)
end if
loop
    if t11 > 12 then
        timeofday1 := (t11 - 12)
        ttt := intstr (timeofday1)
        for i : (Font.Width (timeofday, fontID) * -1) .. (maxx + Font.Width (timeofday, fontID))
            drawfillbox (0, maxy div 2 - 60, maxx, maxy div 2 + 100, 20)
            time (timeofday)
            const len2 := length (timeofday)
            t1 := timeofday (1) + timeofday (2)
            t11 := strint (t1)
            t2 := timeofday (3 .. 8)
            Font.Draw (ttt + t2 + pm, i, maxy div 2, fontID, yellow)
            View.Update
            cls
            delay (1)
            exit when hasch
        end for
    elsif t11 <= 12 then
        timeofday1 := t11
        ttt := intstr (timeofday1)
        for i : (Font.Width (timeofday, fontID) * -1) .. (maxx + Font.Width (timeofday, fontID))
            drawfillbox (0, maxy div 2 - 60, maxx, maxy div 2 + 100, 20)
            time (timeofday)
            const len2 := length (timeofday)
            t1 := timeofday (1) + timeofday (2)
            t11 := strint (t1)
            t2 := timeofday (3 .. 8)
            Font.Draw (ttt + t2 + am, i, maxy div 2, fontID, yellow)
            View.Update
            cls
            delay (1)
            exit when hasch
        end for
    end if
end loop
xmen




PostPosted: Tue Mar 30, 2004 10:06 pm   Post subject: (No subject)

ok another but similar question, the one ive asked above is showing the time to start from the left edge of the screen n goes all the way to the right edge

but is there a way not to do that, but instead hav it start at 200 pixels (x axis) n ends at 600?? so like the text wouldnt touch the edge of the screen at all

anyone knows how??
jonos




PostPosted: Tue Mar 30, 2004 10:18 pm   Post subject: (No subject)

make a for loop:

for i : 200..600
Font.Draw(intstr(timeofday), i, 100, fontThing)
end for

i think that will work, im not sure about the intstr because i don't really know if the time is an integer or a string :/
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: