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

Username:   Password: 
 RegisterRegister   
 Timer Code Help!!! Pleassee Help Thank You
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
Beefmaster




PostPosted: Mon Jan 17, 2011 6:42 pm   Post subject: Timer Code Help!!! Pleassee Help Thank You

What is it you are trying to achieve?
I am trying to put in a timer in my game without using any delays because delays will slow my program down by ALOT.


What is the problem you are having?
I do not know how to create a timer without using delays. Or if I use Time.Elapsed it slows my whole game down and then it shows all the past numbers that have been counted down. All I want is a simple count down from 60 seconds that will actually erase the pass numbers. Like 60 and then 60 goes away and then shows 59 and then 59 goes away and then shows 58, and so on. However, if I use the "cls" command to erase the past numbers, it erases everything and all my pictures on the page. PLEASE HELP ME!! MY GAME IS DUE TOMMOROW!! ANY HELP IS APPRECIATED


below is the code for the timer i am using right now. It does not work right now because it slows my game down and it shows all the past numbers that have been counted.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
var last, now, countDown : int := 100

last := Time.Elapsed

put countDown

loop
now := Time.Elapsed
if (now - last >= 1000) then
countDown -= 1

put countDown
last := now
end if
end loop



Please specify what version of Turing you are using
4.1.1

PLEASE HELP ME IT IS DUE TOMOROW!! THANK YOU SO MUCH
 
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Mon Jan 17, 2011 9:00 pm   Post subject: RE:Timer Code Help!!! Pleassee Help Thank You

just do a bit more math.
Time.Elapsed shows milisecs since program starts.

var sec, min, hrs: int --with math can get a timer set up

Also -> do delay with it, use a BOOLEAN so you know when say 1 min passed, then toggle it to activate whatever, reset boolean and start that counter over.
 
Beefmaster




PostPosted: Mon Jan 17, 2011 9:49 pm   Post subject: RE:Timer Code Help!!! Pleassee Help Thank You

o trueee...wait but how can i change Time.Elapsed from milisecs into seconds? and I'm really bad at programming...do you please mind explaining how I can put booleans and counters in?
and thanks a lot for the help man Smile
 
TokenHerbz




PostPosted: Mon Jan 17, 2011 10:07 pm   Post subject: RE:Timer Code Help!!! Pleassee Help Thank You

its more to do with math... div the miliseconds by 1000 = 1 second.
 
Beefmaster




PostPosted: Mon Jan 17, 2011 10:20 pm   Post subject: RE:Timer Code Help!!! Pleassee Help Thank You

ok ok so i got the timer to work now and i got it to count down from 60 seconds but its showing like
60
59
58
57
56
55
and so on and so on. How do you think I can just have the numbers counting down and not showing the past numbers. Like...
60 and then 60 disappears and then
59 and then 59 disappears and then
58 and so on in the same place?
 
TerranceN




PostPosted: Mon Jan 17, 2011 10:55 pm   Post subject: RE:Timer Code Help!!! Pleassee Help Thank You

You could use cls to clear the screen, and locate to tell Turing where you want the put command to write.
 
Beefmaster




PostPosted: Tue Jan 18, 2011 8:36 am   Post subject: RE:Timer Code Help!!! Pleassee Help Thank You

@TerranceN true but if i use cls it clears like the whole page and all my pictures on the page...is there way where i can just clear text or specific things?
 
Tony




PostPosted: Tue Jan 18, 2011 10:11 am   Post subject: Re: RE:Timer Code Help!!! Pleassee Help Thank You

yes.
TerranceN @ Mon Jan 17, 2011 10:55 pm wrote:
and locate to tell Turing where you want the put command to write.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
 
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: