schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Running a headless simulation as fast as possible? #235

Closed tobloef closed 8 years ago

tobloef commented 8 years ago

For a project I'm working on I would like to do some "off-camera", or headless, physics simulations, as fast as possible of course. The simulation loop wouldn't be tied to any graphics update and should go as fast as the CPU would allow. How can I do this?

Thank you.

schteppe commented 8 years ago

Hi. Just run world.step(dt) in a for loop? Check the current time using world.time.

tobloef commented 8 years ago

@schteppe Great, thanks! I can't believe it was that simple. Really looking forward to working more with p2.js.