04.06.2012, 21:15
I know this is not entirely related to Pawn scripting, but I just can't stop thinking: how do timers work?
I've been asking myself this because I'm developing a pong clone for my programming class, and need to run functions after a determined amount of time, such as speed increasing and menu related stuff. I created a delay function using ticks to better control the speed of the ball, but it just wouldn't work for speed increasing, since I want to increase speed every ten seconds.
What I mean is: How would a SetTimer function look like in assembly code, for example? Would it be like a main loop running constantly and checking if an amount of time has passed? If I'm running a program, which has an order of execution, calling a function by a timer would be like interrupting this order of execution to do another function, and then returning to the original point?
I know these will be newbie questions for some, but I am very curious about this.
I've been asking myself this because I'm developing a pong clone for my programming class, and need to run functions after a determined amount of time, such as speed increasing and menu related stuff. I created a delay function using ticks to better control the speed of the ball, but it just wouldn't work for speed increasing, since I want to increase speed every ten seconds.
What I mean is: How would a SetTimer function look like in assembly code, for example? Would it be like a main loop running constantly and checking if an amount of time has passed? If I'm running a program, which has an order of execution, calling a function by a timer would be like interrupting this order of execution to do another function, and then returning to the original point?
I know these will be newbie questions for some, but I am very curious about this.