Central Update Loop and Timing
by Scott Markwell · in Torque Game Builder · 03/03/2005 (12:01 pm) · 3 replies
Ok, I picked up T2D a few days ago (apparently I managed to buy it shortly after it was released unknown to me :) ). I was currently working a 2d side scroller in C++/Win32/D3D, setting it up to load nonpower of 2 texs, having 2d line intersection collisions using custom 2d poly's per frame of animation, with multiple collisions boxes per object/frame so that on the 2nd stage of collision detection I could determine if the player is taking damage, or doing it.
Anyways, I've been studying the documentation (a little rough but I don't mind, being early and all), and unless I'm missing something, the entire event states are reactionary, (to a key press, collision, start of application etc) and I wanted to have a central update location (not closed, simply something that is perodically called) so I can control and clamp the acceleration of objects as the player moves. schedule() looks to be a proper solution to what I'm looking for now that I think about it.
which i guess leaves me with one question, where can I get current uptime MS?
as getSceneTime() returns the scene time's frame elapsed which I could use, but is there something that returns the system's uptime or another ms accurate timing system?
Anyways, I've been studying the documentation (a little rough but I don't mind, being early and all), and unless I'm missing something, the entire event states are reactionary, (to a key press, collision, start of application etc) and I wanted to have a central update location (not closed, simply something that is perodically called) so I can control and clamp the acceleration of objects as the player moves. schedule() looks to be a proper solution to what I'm looking for now that I think about it.
which i guess leaves me with one question, where can I get current uptime MS?
as getSceneTime() returns the scene time's frame elapsed which I could use, but is there something that returns the system's uptime or another ms accurate timing system?
About the author
#2
I guess I'm going to spend more time reading up on T2D before I end up redoing a bunch of functionality already implemented ;)
I'm new to Toruge Script, but it's reminisent of Tribes 1 Script, (i wonder why ;) ). If you have any amazing tutorials for the script language syntax that isn't well known, I'd love to know about it.
03/03/2005 (1:04 pm)
Well I'm used to doing low level stuff for cell phones in C++ so I'm not used to having so many options already available to me already.I guess I'm going to spend more time reading up on T2D before I end up redoing a bunch of functionality already implemented ;)
I'm new to Toruge Script, but it's reminisent of Tribes 1 Script, (i wonder why ;) ). If you have any amazing tutorials for the script language syntax that isn't well known, I'd love to know about it.
#3
Don't want to change your way of thinking at all though; you've probably got fresh ideas, especially if you've had to work hard within the limited confines of cell-phone hardware. Necessity is the mother of invention!
Just try to let T2D do some of the hard work first just to see how far you can push it. :)
- Melv.
03/03/2005 (1:14 pm)
@Scott: Have a browse through these forums, there are quite a few posts to documentation links. You can get to the Official Torque-Script documentation.Don't want to change your way of thinking at all though; you've probably got fresh ideas, especially if you've had to work hard within the limited confines of cell-phone hardware. Necessity is the mother of invention!
Just try to let T2D do some of the hard work first just to see how far you can push it. :)
- Melv.
Associate Melv May
If you don't mind me saying, your looking at doing lots of manual work in scripts that T2D will happily do for you.
T2Ds physics can accelerate objects and you can specify things like maximum linear/angular velocities. You can set velocities directly, apply impulse forces or continuous forces as well. You can limit areas that the objects can move and have automatic collision responses applied. All this is done very fast within T2D.
T2D isn't really about having the old-school main-loop where you start manually controlling/capping velocities/positions etc. It does provide a callback that's actioned each frame called "fxSceneGraph2D:onUpdateScene(%this)". In here you can call the "getSceneTime()" function you mentioned, or anywhere else for that matter. You've just got to be careful doing too much stuff here otherwise you can seriously hurt performance.
Essentiall, you shouldn't need to get low-level, that's the whole point of T2D. Getting your games running quickly without worrying about all the details.
Sorry if you already knew some of this stuff but I just wanted to ensure that you started off on the right track. :)
If you've got any further questions then I'd be glad to answer them.
Hope this helps,
- Melv.