Towards the end of developing SpaceSquid, my poor programming was catching up with me. Writing code quickly != quick running code. I think I iterated through the entire world object list several times per tick...
Anyway, I wanted to sit down and actually write out a nice box of parts I could pull on to make Box2D games quickly and easily. Here's what I've come up with so far.
It's nothing to exciting, in and of itself, but the back end is cool. Some controls:
- Mouse drag and drop to move the screen
- Mousewheel for zoom
- Keyboard arrows for moving the screen
- Z/X to zoom In/Out
- <> control the gravity.
The simulation doesn't really have much to it. The 4 objects that appear are representations; from left to right:
- A cellphone (the minimum Box2D object size, 0.1m)
- A person (6ft)
- An office story (12ft)
- A bus (the maximum Box2D object size, 10m)
For the time being I've given them all the density of water (1000 kg/m^2 [@ 4c]) and the gravity starts out at 9.81 m/s^2, so it's fairly realistic and should behave normally out the door.
To make things more interesting, however, I gave the 4 objects a restitution of 101%, so they actually gain energy anytime they hit something.
If you carefully tap the "<" key you can make it weightless and watch things drift around. Relaxing!
Cool. I've generally had better luck writing a framework/library/engine to match the things in my existing program, than to write the framework/library/engine first, before I've written a game.
ReplyDelete