Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loops and timers
#1
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?
Reply
#2
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...
Reply
#3
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.
Reply
#4
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.
Reply
#5
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.
Reply
#6
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.
Reply
#7
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.
Reply
#8
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. Tongue
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)