Maze
Author |
Message |
shruti
|
Posted: 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

|
|
 |
Tony

|
|
|
|
 |
[Gandalf]

|
Posted: 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
|
Posted: 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

|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
|
|