| Mirage Source http://web.miragesource.net/forums/ |
|
| Loops and timers http://web.miragesource.net/forums/viewtopic.php?f=201&t=3113 |
Page 1 of 1 |
| Author: | Beres [ Tue Dec 04, 2007 8:35 am ] |
| Post subject: | Loops and timers |
I am just curious, what is a better way to handle something? With a timer or a loop? Which way is more faster, or better? |
|
| Author: | Rezeyu [ Tue Dec 04, 2007 8:39 am ] |
| Post subject: | Re: Loops and timers |
Well.. You use loops to loop through things.. And timers to you know.. time things. They aren't really the same thing at all.. I don't know why you'd want to use either of them in place of the other... |
|
| Author: | Beres [ Tue Dec 04, 2007 8:41 am ] |
| Post subject: | Re: Loops and timers |
Well awhile ago someone told me (dont remember who) to use a loop instead of the timer cuz a timer slows something down or what ever. I was just wondering. |
|
| Author: | William [ Tue Dec 04, 2007 10:22 am ] |
| Post subject: | Re: Loops and timers |
They didn't tell you to use a loop instead of a timer. They told you to replace your timer witha small peice of code you put in your game loop. There is a tut for it. |
|
| Author: | Spodi [ Tue Dec 04, 2007 12:36 pm ] |
| Post subject: | Re: Loops and timers |
Correct answer is "It depends". For a game loop, you want a loop, not a timer. Reason for this is you have complete control on how frequent things execute. With a timer, your code has to hit an idling point or a DoEvents to trigger, along with the resolution is quite low (if you say 5 milliseconds, it may be anywhere from 5 to 25 before it actually fires). It also removes needless overhead, though this isn't of much concern, since its hardly noticeable, unless you have like 50 timers. |
|
| Author: | Beres [ Tue Dec 04, 2007 7:48 pm ] |
| Post subject: | Re: Loops and timers |
William wrote: They didn't tell you to use a loop instead of a timer. They told you to replace your timer witha small peice of code you put in your game loop. There is a tut for it. No really, they DID tell me lol! Is some guy I knew from school. |
|
| Author: | Matt [ Tue Dec 04, 2007 8:04 pm ] |
| Post subject: | Re: Loops and timers |
Well, it's possible to loop with a timer, just not practical. Could set the interval to 1000 (1 second) and then in the timer code do: Code: a as long a = a + 1 if a = 60 then ' 1 minute do stuff end if I used to do that, when I first started and didn't fully understand how to use loops and stuff. |
|
| Author: | Beres [ Tue Dec 04, 2007 8:07 pm ] |
| Post subject: | Re: Loops and timers |
Yeah well I wasnt sure if he was playing me or telling the truth so I decided to ask you guys. And thats how I use to use things lol, pretty funny. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|