![]() |
Loops and timers - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17) +---- Thread: Loops and timers (/showthread.php?tid=1433) |
Loops and timers - Beres - 04-12-2007 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? Re: Loops and timers - Rezeyu - 04-12-2007 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... Re: Loops and timers - Beres - 04-12-2007 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. Re: Loops and timers - William - 04-12-2007 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. Re: Loops and timers - Spodi - 04-12-2007 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. Re: Loops and timers - Beres - 04-12-2007 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. Re: Loops and timers - Matt - 04-12-2007 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 I used to do that, when I first started and didn't fully understand how to use loops and stuff. Re: Loops and timers - Beres - 04-12-2007 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. ![]() |