Sign in to follow this  
Ezbez

Run a script every X ms?

Recommended Posts

I'm working on using Python to script my game right now, and I'm considering an idea that I just had. Currently, I have an OnFrame script that is, well, run once every frame. However, I thought that perhaps having a frame that isn't run based on framerate, but instead run every X milliseconds (frames that don't take X milliseconds would leave LengthOfFrame % X milliseconds for the next frame to handle). It seems logical and that it would certainly make frame-rate independent events easier to use. Do you think that this would be worth the extra effort? If it is, what do you think would be a good X to use? Thanks in advanced.

Share this post


Link to post
Share on other sites
I would actually take that a bit further and not execute any script code at all unless an event occurs. If you want to implement some sort of timer functionality into the script system, then handle all the timer logic in native code. This doesn't have to be a hard and fast rule, but depending on how much of your game logic you eventually put in script you want to cut down the amount of time you spend there early on, rather than making comprises in the logic itself later on. This also means you should try to keep your game logic as event-based as possible and minimize update-based functionality.

Share this post


Link to post
Share on other sites
I agree with Zipster. Adding scripting to a host application seems easy enough, but needs to be carefully thought-out in order to be efficient, especially for large-scale applications.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zipster
I would actually take that a bit further and not execute any script code at all unless an event occurs. If you want to implement some sort of timer functionality into the script system, then handle all the timer logic in native code. This doesn't have to be a hard and fast rule, but depending on how much of your game logic you eventually put in script you want to cut down the amount of time you spend there early on, rather than making comprises in the logic itself later on. This also means you should try to keep your game logic as event-based as possible and minimize update-based functionality.


Hmm... I haven't quite understood how this is going to work. So, I'm going to come up with an example. Say, I've got a homing missle that is targetting the player. How would that work in an event-based system?

FYI, every year my family and I get together and all run a big Christmas script while singing carols. ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this