Posted By: wraggster
News/release from Oxtob
I really like the idea of the popular mini game Crayon Physics: You draw an object on the screen and it instantly becomes physical and interacts with other objects. The first thing that sprung to my mind when seeing it was "This would be awesome on the DS!" And Pocket Physics is what I came up with after two weeks. It isn't really a game, but more of a physical construction kit for your pocket. You can design scenes freely by drawing things with the stylus. Things can be solid, like ramps and floors, or dynamic, like balls or boxes. Like in The Incredible Machine, you can reset the scene, change it, and start the simulation again. It's even more fun if you have a DS Motion, which can be used to control gravity!
This version was quite a lot of debugging work, but I'm really satistied with the result. There's good and bad news about the changes.
I'll tell you the bad news first:
There are no new features, except for deleting sketches.
Many of your existing sketches will no longer load in this version and if they do they will behave differently. This is due to changed in the new version of Box2D and also due to my optimizations. If you want to "rescue" a sketch, open the pp file in a text editor and check that all boxes are at least 6 pixels wide and that there are no extremely small or thin polygon shapes in there.
The PP file format has changed because I introduced a root node to make the XML compliant. The old files will still load, but those of you who have written parser code for websites will have to update their code.
Certain changes led to heavy objects being "restless" when lying on a flat surface.
And the good news is:
Simulation is now incredibly fast! I optimized the hell out of it and it still runs at acceptable speed with 50 circles on the screen. This is probably as fast as it will get.
Box2D now officially supports fixed point math and the DS target! Erin Catto has added the patches by Kavaler and me to the official SVN! Yay! Thanks a lot to Kavaler for his help with the fixed point port!
I fixed the "explosion" bug. In case you're interested in what caused it: I'm using the DS's hardware div and sqrt functions both in the physics and in the drawing code. Usually the physics code gets interrupted by the drawing code. Now if the physics code was just waiting for a division result while being interrupted by the graphics, the result will be overwritten by the graphics code. When execution of the physics code in continued it will read back the wrong division result, which can have dramatic consequences. This also caused a lot of randomness and probably crashes. I fixed it by remembering the division/sqrt register values at the beginning of the vblank interrupt handler and writing them back at the end. Also, because of this fix:
The randomness is gone! Everything is 100% deterministic now.
There are no more crashes! Really, I can't get it to crash any more. If you can, please show me the pp file!
Download and Give Feedback Via Comments