Open erodozer opened 10 years ago
@mdsitton Since you've been pretty active lately, could you look at focusing efforts on getting this implemented? It shouldn't be too hard is it can just be a globally accessible clock that's updated according to the render method. It'd be rather helpful with cleaning up code and making things more precise/predicable.
So let me clarify this a bit. So basically you want to see a globally accessable delta time clock somewhere?
Well a while back I did a decent amount of work replacing the pygame clock stuff because of some issues i was finding with it. in GameEngine: self.tickDelta or self.clock.deltaTime
These are almost what you are asking about. Unless your wanting it importable at a module level for ease of access.
Either as a module or as a parameter passed to any Scene's render/update method. If it's already in GameEngine I guess that's fine, but I'd still rather like it if we moved away from GameEngine being a global container of values that everything has to depend on.
Technically I could make a pseudo module by injecting some stuff into sys.modules... Something like this: https://gist.github.com/mdsitton/e19fb13dfcd0350afbc3
And technically we could build some kind of virtual package structure as well. but the main limitation with that is you wouldn't be able to properly use the from import syntax: from DeltaTime import deltaTime
And actually that last limitation would apply to anything where we are changing the value constantly in the module. So thats not exactly a specific limitation of that code.
but if we provided functions to get those vars you could do the from import on those and it would work fine...
A lot of the game uses hard-coded values or are dependent on game cycle speed to perform animations. Instead, we should be using a timer resolution (also refered to as DeltaTime by some) to be doing multiplicative, yet precise, tweening of values to ensure a consistent look and feel regardless of FPS.