Computer Science Canada time.elapsed not working well |
Author: | poolshark1691 [ Mon Apr 30, 2007 9:43 pm ] | ||
Post subject: | time.elapsed not working well | ||
Hello, this is my first time posting! currently i have a time.elapsed function where if it finds that 30 seconds have passed, it goes to a procedure to start a new level of my game. and then what happens is, after 45 seconds, it restarts again, then after 60 seconds, it restarts again... the good thing is, after 30 seconds, it works all fine and dandy, but for the 45+ second stuff, it stops working. I have two variables:
Edited by Clayton: Please remember to use code tags |
Author: | rollerdude [ Tue May 01, 2007 2:02 pm ] | ||
Post subject: | Re: time.elapsed not working well | ||
i see your problem and fortunately, i have an answer now first of all, i'd like to say, before clayton edits your post, that when you submit code, you put in the code tages (when you write your post, click on "more tags" then on "code") this way, it makes it easier to distiguish from your post second, i have noticed that you use elsif, thats fine, but the way you have it set up, is that the first part of your if statment (the part that says if time2-time1>=30000 then...) will always return true, and then skip the rest of the statment. for this to work, you will have to write the time in reverse, like so:
P.S. see what i mean about code tags? |
Author: | rollerdude [ Tue May 01, 2007 2:04 pm ] |
Post subject: | Re: time.elapsed not working well |
sorry, but by the way... time2:=Time.Elapsed has to be in loop keep on working! |
Author: | poolshark1691 [ Tue May 01, 2007 7:41 pm ] | ||
Post subject: | Re: time.elapsed not working well | ||
Thank you very much for your response ![]() I made an error with time2, it should go before restartprocedure. Because i want it to count it once that procedure has started. Could you please tell me what is wrong with "elsif"? should i jus be using standalone "if" statements? And i will remember to use the code tag next time!!! Sorry for the mistake! Alright, i now have a level system, where after each time interval (so 30 seconds, 45 seconds, etc.) the level increases and it evaluates the timelimit based on the level. So:
and the level increase and evaluation of timelimit go for 10 levels, with the 10th level evaluating for 165 seconds. and i am still having the problem. |
Author: | rollerdude [ Wed May 02, 2007 9:51 am ] | ||||
Post subject: | Re: time.elapsed not working well | ||||
elsifs are fine, but maybe i'l' have to explain again...
after 30 seconds the line "if time2 - time1 >= 30000 then" will always return true, regarless of what time it is, because 46000 is greater than 30000.. so... for this to work, you will have to write your times in reverse, meaning that instead of 30000 then 45000 then 60000, you will have to have 6000 THEN 45000 THEN 30000 like so...
i hope this will help... |
Author: | poolshark1691 [ Fri May 04, 2007 7:14 pm ] |
Post subject: | Re: time.elapsed not working well |
I wanna apologize for not replying sooner. I want to let you know that your help worked. Thank you very much! |