1
Script / Re: Help Using Timers in Scripted Game Dev?
« on: 2006-11-20, 05:54:20 PM »
This is actually the solution I was able to ferret out by digging through threads, following a link to forums, and following a link from there to more forums. :0 I managed to get a basic timer working in game using the approach of incrementing a player inventory item each frame and basing the timing of functions off that. My only concern would be how much processing power such a mechanism takes up.
I don't see it being a big issue with one timer. However, what if I want two timers running simultaneously? Four? Eight? It seems to me the load on the game engine could get quite heavy given enough use of timers, and though there are cases where you could reuse the same timer, I'm assuming you will have to have some timers running independently in cases where both timers may need to be running at once (for instance, a cooldown on use of a spell PLUS a cooldown on your invincibility buff).
Basically, the incrementing an inventory item approach works (going by 60 = 1 second) but the impact it has on gameplay worries me. How big a hit do you think a game takes from running multiple timers? (which I'm assuming must always be running in the background, as the function to increment them is played in OnAfterMoveSprites).
I don't see it being a big issue with one timer. However, what if I want two timers running simultaneously? Four? Eight? It seems to me the load on the game engine could get quite heavy given enough use of timers, and though there are cases where you could reuse the same timer, I'm assuming you will have to have some timers running independently in cases where both timers may need to be running at once (for instance, a cooldown on use of a spell PLUS a cooldown on your invincibility buff).
Basically, the incrementing an inventory item approach works (going by 60 = 1 second) but the impact it has on gameplay worries me. How big a hit do you think a game takes from running multiple timers? (which I'm assuming must always be running in the background, as the function to increment them is played in OnAfterMoveSprites).