syncing the game to a constant fps.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

If animations are too fast, node->setAnimationSpeed() would do it, no matter the refresh frequency.
- animation are not the problem they work right as they are fps / time based anyways.

arras, This is sort of what I was trying to get at. But for my I'm dev'ing on a very slow system. And I dont see anyone try on a slow one. But it is possible, I can't rule it out. I agree with the approach you mentioned. Just, was not sure how to track a globe unit, or rather calculate it. I guess I could put some code in my update and get before and after times and some how get the unit i need.. I may give this a go. This is what I did to fix the animation call in the irrlicht code so that the animation speed could be changed on the fly. Thx for the idea..

maybe somthing like

Code: Select all

			s32 timeNow = device->getTimer()->getTime();
			s32 elapsedTime = timeNow - lastTime;
			lastTime = timeNow;

Nox's solution work great for the mean time.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Yes, that code will work. Just implement it the right way (which depend on your application). Somehow you have to make elapsedTime available in part of code which is responsible for your actions on nodes.
Nox
Posts: 304
Joined: Wed Jan 14, 2009 6:23 pm

Post by Nox »

Well in fact i use this for my codes (no irrlicht solution but only as a hint):

Code: Select all

while(run)
{
	SYSTEM_TICKS DeltaMS = act_time.GetDiffMSTick();
	act_time.TimeStamp();
	Sector->Update(DeltaMS);

	Sector->TimeNeeded = act_time.GetDiffMSTick();
	if(TIMEFORSECTORTHREAD > Sector->TimeNeeded)
		PortableSleep(TIMEFORSECTORTHREAD - Sector->TimeNeeded);
}
ulao
Posts: 274
Joined: Fri Mar 28, 2008 2:13 am

Post by ulao »

Ya I have put that in my general update and will be able to pass it down the update chain.

I planned on doing it like Nox did.

Thx to you both.
Post Reply