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

Username:   Password: 
 RegisterRegister   
 Timer
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
WhatAmIDoing




PostPosted: Tue Apr 20, 2004 1:34 pm   Post subject: Timer

i was bored and trying to make a good looking timer
setscreen ("graphics:200;100")
var Min, Sec, Hrs, MSec : int := 0
colorback (black)
cls
color (brightgreen)
loop

Sec += 1
if Sec = 60 then
Sec := 0
Min += 1
end if
if Min = 60 then
Min := 0
Hrs += 1
end if
locate (1, 1)
put Hrs, " HRS"
locate (1, 10)
put Min, " MIN"
locate (1, 20)
put Sec, " SEC"
delay(1000)
end loop
Sponsor
Sponsor
Sponsor
sponsor
Delos




PostPosted: Tue Apr 20, 2004 4:45 pm   Post subject: (No subject)

Delays are bad. They are bad because there are never working. Always, never working. Why? Because they are bad, always. And different! On all computers, so always, never. Bad and bad. "Good!" they say, "We are" they say, then they jump at me and beat me down with sticks. And they are bad like techno with bagpipes. Always!

Yeah, try Time.Elapsed instead.


And for those who do not recognize the speach impediment pattern above, it is the classic Depressed Persian Tow Truck Man, from Mad TV.
Tony




PostPosted: Tue Apr 20, 2004 6:48 pm   Post subject: (No subject)

Delos is right. You shouldn't be using delays. And when you are (to slow game down for example) - don't hardcode them, use variables instead and adjust the delay based on CPU speed
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Delos




PostPosted: Tue Apr 20, 2004 6:49 pm   Post subject: (No subject)

tony wrote:
...and adjust the delay based on CPU speed...


Tony, is there any way of doing this without having the User enter their CPU speed manually???
Tony




PostPosted: Tue Apr 20, 2004 7:08 pm   Post subject: (No subject)

well I was refering to FPS implemination
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
WhatAmIDoing




PostPosted: Wed Apr 21, 2004 7:52 am   Post subject: (No subject)

ok i'll try to implement that into but i still not completly sure of how it works. any way thanks for the tip.
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: