Author |
Message |
Ballack1919
|
Posted: Tue Jun 13, 2006 6:26 pm Post subject: URGENT Turing Timer Help needed |
|
|
I am new to this site and am looking for urgent hewlp which i will appreciate. I am doing a game and need a timer from like 3 mins going backwards and looping untill it gets to zero and the time is over. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
TheOneTrueGod

|
Posted: Tue Jun 13, 2006 6:31 pm Post subject: (No subject) |
|
|
Search the Turing F10 menu for Time.Elapsed. It will give you the amount of time that has elapsed in the program, in milliseconds. Using some math, you should be able to convert this into whatever time you want (1000 ms in a second, 60 seconds in a minute...) |
|
|
|
|
 |
Ballack1919
|
Posted: Tue Jun 13, 2006 6:36 pm Post subject: (No subject) |
|
|
Thanks for the reply but as i said before i am making a game for turing, and the timer. How would the timer work as the game is running. |
|
|
|
|
 |
Clayton

|
Posted: Tue Jun 13, 2006 6:44 pm Post subject: (No subject) |
|
|
put the timer in a loop, keep a variable to keep track of how much time has elapsed, once three minutes is up exit the loop, done |
|
|
|
|
 |
Ballack1919
|
Posted: Tue Jun 13, 2006 7:12 pm Post subject: (No subject) |
|
|
can any one please whow me an example, please because i dunt really know this |
|
|
|
|
 |
Guest
|
Posted: Tue Jun 13, 2006 7:19 pm Post subject: (No subject) |
|
|
He is new to Turing, I think you confused him. Make a variable and set it to any number. Then if you know how to use a loop, you can make the variable decrease by 1 as long as it is in the loop. For example:
code: |
var x : int := 1 %sets x to 1
loop
put x
x := x+1 %increases x by 1
end loop
|
Then if you wish to decrease it, try this:
code: |
var x : int := 1
loop
put x
x := x-1 %decreases x by 1
end loop
|
Now you can combine those two, by using exit statments:
code: |
var x : int := 30
loop
put x
x -= 1 %same as x:= x-1, only shorter
exit when x = 5
end loop
loop
put x
x += 1
exit when x = 30
end loop
|
If you wish to make this much simpler, learn how to use FOR LOOPS. eg:
code: |
for i : 1 .. 30
put i
end for
for decreasing i : 30 .. 1
put i
end for
|
Those are the basics in looping. Exit statments can be used inside any loop. |
|
|
|
|
 |
Ballack1919
|
Posted: Tue Jun 13, 2006 7:37 pm Post subject: (No subject) |
|
|
Thank You that helped alot, Now I just have to add the timer to my program and it will be finished, Once again thnx to all |
|
|
|
|
 |
Bored

|
Posted: Tue Jun 13, 2006 8:23 pm Post subject: (No subject) |
|
|
I personally do not like to use Time.Elapsed for timers in my programs. I find that that's unfair to those of different computer speeds though at his level that may not be important. Sure you may throw in a Time.DelaySinceLast to keep it running at the same speed but that does not always work in larger programs, where sometimes it takes the CPU longer then the target speed. Though that is not the problem yet learning proper procedure now helps down the line. Now you may be thinking, well what would you do, well simple.
code: | const del := 10
var timeElapsed := 0
loop
%program here
timeElapsed += del
Time.DelaySinceLast (del)
end loop |
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Clayton

|
Posted: Tue Jun 13, 2006 8:55 pm Post subject: (No subject) |
|
|
the only problem there is you do not know exactly how long your code exectution is going to take, you can only guess, and code execution takes a different amount of time depending on your processor, making it even less acurate, better to just use Time.Elapsed even if it isnt 100% accurate  |
|
|
|
|
 |
Bored

|
Posted: Tue Jun 13, 2006 8:58 pm Post subject: (No subject) |
|
|
Yes it may not be time acurate but it is acurate to the number of rounds. I mean if you have to get from point A to point B, why should one person get 100 movements wherea as another only gets 75. Mine thoug 100% accurate on the average user compensates for those who are at a disadvantage from their computers snail paced processing. |
|
|
|
|
 |
|