04-12-2007, 08:35 AM
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?
Loops and timers
|
04-12-2007, 08:35 AM
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?
04-12-2007, 08:39 AM
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...
04-12-2007, 08:41 AM
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.
04-12-2007, 10:22 AM
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.
04-12-2007, 12:36 PM
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.
04-12-2007, 07:48 PM
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.
04-12-2007, 08:04 PM
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.
04-12-2007, 08:07 PM
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.
![]() |
« Next Oldest | Next Newest »
|