
-----------------------------------
shruti
Sun May 11, 2008 1:42 pm

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

-----------------------------------
Tony
Sun May 11, 2008 1:59 pm

RE:Maze
-----------------------------------
yes.

-----------------------------------
[Gandalf]
Sun May 11, 2008 4:31 pm

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:
var timeLowRange := 5
var timeHighRange := 15
var time := Time.Elapsed
if time > timeLowRange and time < timeHighRange then
   ...
end if

-----------------------------------
jinjin
Sun May 11, 2008 4:42 pm

Re: Maze
-----------------------------------
Alternatively, you could use a delay loop to count time. For example, here is a simple second timer using one loop:


var timex : int
timex := 0
loop
    delay (1000)
    timex += 1
    put timex, " seconds have passed!"
end loop


-----------------------------------
Tony
Sun May 11, 2008 5:10 pm

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.
