Computer Science Canada Timer Issues |
Author: | Clayton [ Tue Aug 08, 2006 2:31 pm ] | ||
Post subject: | Timer Issues | ||
ok, im working on a game right now and im having some problems coming up with a reliable way to keep track of n timers without screwing up the screen, and noticeably slowing down the game, at first i thought of a procedure, but couldnt get it to work quite right, so i went to a process, but its still not working, heres what i have so far, if anybody could help it would be much appreciated ![]()
|
Author: | Windsurfer [ Tue Aug 08, 2006 3:03 pm ] |
Post subject: | |
I think the code here is mostly right, i just think there's a problem with the way this interacts with the rest of your code. I see that you are using this process to not only keep track of the seconds, but also to display the timer. Since this is a process, and you are using View.Update, this will reign hell upon earth. Why process are evil. I reccomend that instead of having a process like this keep track of your timers, and take up 50% of your resources per timer, i suggest you develop a way to record Time.Elapsed at a certain point in your code, and then, for every iteration of your main loop, compare the old time to the new Time.Elapsed, until the desired difference is reached(eg. Time.Elapsed - old_time >= 10000 would be a ten second timer). Also, display the timer in your main loop too, so that you don't get any unpredictable flickering when using View.Update. |
Author: | Clayton [ Tue Aug 08, 2006 3:06 pm ] |
Post subject: | |
that View.Update was in there from before when it was a proc, ive read that article many a time trust me. i just had this one process in there for now until i could figure out what was going on with my procs... |
Author: | Windsurfer [ Tue Aug 08, 2006 3:11 pm ] |
Post subject: | |
Soo.... what's your question? ![]() |
Author: | Clayton [ Tue Aug 08, 2006 3:13 pm ] |
Post subject: | |
my question is how can i get that (above code) to allow me to have multiple timers going while still looking at least half decent... |
Author: | Windsurfer [ Tue Aug 08, 2006 3:20 pm ] | ||
Post subject: | |||
Make an array? Perhaps of real numbers, that you Quote: ...record Time.Elapsed at a certain point in your code, and then, for every iteration of your main loop, compare the old time to the new Time.Elapsed, until the desired difference is reached(eg. Time.Elapsed - old_time >= 10000 would be a ten second timer). Start off with this, perhaps:
|
Author: | TokenHerbz [ Thu Aug 10, 2006 11:30 am ] |
Post subject: | |
cant you just "fork" the process? |
Author: | Windsurfer [ Thu Aug 10, 2006 12:47 pm ] |
Post subject: | |
TokenHerbz wrote: cant you just "fork" the process? ~slaps poster and commits suicide by keyboard ~ jgamtpgjhkn.... |