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

Username:   Password: 
 RegisterRegister   
 Maze
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
shruti




PostPosted: Sun May 11, 2008 1:42 pm   Post subject: Maze

hi i am making a maze so i was wondering if i can have time limits like use if structure
if Time.Elasped=5 then
put " ......"
can i do that ????????????????????
thanks
 
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun May 11, 2008 1:59 pm   Post subject: RE:Maze

yes.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
 
[Gandalf]




PostPosted: Sun May 11, 2008 4:31 pm   Post subject: RE:Maze

Yep, but keep in mind that since nothing is instantaneous on a computer, you'll have a hard time reaching whatever exact values you choose. You'd be better off using ranges, such as:
code:
var timeLowRange := 5
var timeHighRange := 15
var time := Time.Elapsed
if time > timeLowRange and time < timeHighRange then
   ...
end if
 
jinjin




PostPosted: Sun May 11, 2008 4:42 pm   Post subject: Re: Maze

Alternatively, you could use a delay loop to count time. For example, here is a simple second timer using one loop:

Turing:

var timex : int
timex := 0
loop
    delay (1000)
    timex += 1
    put timex, " seconds have passed!"
end loop
 
Tony




PostPosted: Sun May 11, 2008 5:10 pm   Post subject: RE:Maze

Not really. You are assuming that delay(1000) will take exactly 1 second and that timex += 1, put, and loop itself take 0 time. Which is obviously not the case. It's a fair estimate for the first few numbers, but the errors accumulate over time.

A better approach is to take the difference between Time measured at one point in the program and Time measured at another.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
 
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  [ 5 Posts ]
Jump to:   


Style:  
Search: