Re: A Little Help

new topic     » goto parent     » topic index » view thread      » older message » newer message
Icy_Viking said...

Thanks for the tips. I've removed the for loop outside of the while loops. The window now stays open. Yeah I thought the C example was bad. I don't think it really works besides showing the physics library version number.

It's likely that NewtonUpdate() needs to be called each frame, so determine how many frames you're getting, and use that to determine your timeStep.

integer frames = 0 
atom elapsedTime = time()+1 
while 1 do  
 
	key = get_key()  
	  
	if key = 27 then  
		exit  
	end if  
	 
        frames += 1 
 
        -- if it's been a second since last calc, re-calc 
        if time() >= elapsedTime then 
            timeStep = elapsedTime / frames 
            frames = 0 
            elapsedTime = time()+1 
        end if 
 
 	NewtonUpdate(world,timeStep)  
  
end while  

In lots of game engines I've played with, the "timeStep" is referred to as the "delta time." You might want to look at that, or see if Newton has some docs on it. You have to use that to get consistent game speed across multiple processors.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu