Planet of the Forklift Kid (Flash)

I made a flash game using Box2DFlash 1.4.3 for a contest:

Image

Play Planet of the Forklift Kid

For you guys, this game might be particularly interesting because it involves b2Shapes representing simple line segments. I was unsatisfied trying to build concave worlds out of convex shapes, so I decided to build a shape class that is just a line segment, and then chain a bunch of these line segments together to create concave worlds.

My code for line segment shapes is not public right now, because it's still pretty buggy, and because it's not compatible with Box2D 2.0, so there's not much point in showing it off. I will probably attempt to remake line segments in 2.0 at some point in the future, though, unless someone else does a better job first. Also, my line segments don't work as dynamic shapes. Only static line segments are supported. Theoretically, they could be made dynamic, but then they wouldn't be nearly as optimized or reliable as convex shapes and it would kinda defeat the purpose. On the other hand, forcing them to be static kinda ruins the purity of the Box2D API. I'm not sure what to do about that, but what I am sure about is that, now that I have used line segments to build my worlds, I definitely don't want to go back to using convex shapes.
Awesome game, though annoyingly fiddly in places. I particularly loved that when you walk over small blocks, they are pushed the other way. Rare to see in a game.

As for your "line segment shapes", do you mean different shape type, or the approach of some some users of constructing line segments out of thin polygons? I presume the former. It's a pity you didn't get to use it more in the game, I only really spotted one area that would be annoying to make out of polygons.

If you did create a new shape type, you should definitely put up some code on this board, buggy or not. Meshes, in Box2d terminology, are a rather advanced feature for Box2D, and is listed in the Todolist. I believe the planned support for them then will also be just for static objects, but is probably a long way away from being implement. The distinction between having several segments in one shape, and having just one is largely unimportant.

I am currently working on updating a new shape type to Box2DAS3 2.0 as well, so pm me if you have anything specific to discuss.
I like your game, it has a fun sensibility. The character is so cute and the music's cool too.

There are some weird parts (like trying to walk past the fork-lift) but overall it works good. Nice job.
BorisTheBrave wrote:
As for your "line segment shapes", do you mean different shape type, or the approach of some some users of constructing line segments out of thin polygons?

Yes, I meant a different shape type.

BorisTheBrave wrote:
The distinction between having several segments in one shape, and having just one is largely unimportant.

That's what I thought too, and it seemed simpler to just use one line segment per shape, so that's what I did. But in hindsight, I can see that it would have been useful to support chains of line segments (meshes? I only know that word in 3D) in a single shape. For example, a lot of the trouble I ran into was in deciding what to do when a polygon shape hits one of the ends of the line segments. It would have helped to have had access to both line segments at a corner at the same time, to decide which way to push the poly. On the other hand, the broadphase collision detection is much more efficient if each line segment is a separate shape, otherwise the entire world would be one big bounding box and the broadphase sweep wouldn't give you any information about which line segment you collided with. I think what I'm going to end up doing in 2.0 is using linked lists of line segments which are individually separate shapes with their own bounding boxes, but with optional links to prev and next line segments to help it decide what to do about corner collisions.

BorisTheBrave wrote:
If you did create a new shape type, you should definitely put up some code on this board, buggy or not.

Well, my code is also embarrassingly unreadable, because I was mostly just trying things out until I got it to work, and then didn't spend the time to go back and clean it up. 😛 So it's not really useful for learning purposes either, but if anyone wants to try it out anyway you can PM me for the code.
My line shapes will not work in 2.0, no. And I'm afraid I'm not going port them until skatehead finishes porting Box2D 2.0.1 to Flash, because a bunch of things changed between 2.0.0 and 2.0.1, and the contact listeners in 2.0.0 are kinda broken. I use contact listeners a lot, so I'm just gonna have to wait until I know I can rely on them and the code base that I'm working with is relatively stable. Sorry, but you're gonna have use thin boxes for now.

On the plus side, you can make those boxes almost infinitely thin and you won't have to worry about things clipping through them, thanks to continuous collision detection. 😎

And I'm happy to see that there's demand for line shapes. I hope I'll be able to satisfy everyone's line shape needs soon.
fun little game i like the art style too nice work.
I think my line shapes were more optimized than narrow boxes. Additionally, my line shapes were one-way, meaning you could pass through from one side, though I did not make use of that fact in Forklift Kid because my implementation didn't work very well as a one-way platform.
Any update on this? I'm desperate for some line-shapes in Box2D.

If you want to show the old code, I'll put in the hard-yards and attempt to get it working with v2.1.

Nice game by the way!
I will have it ported in no more than one week from right now. 🙂
Awesome! Thanks! 😀

Original thread: https://box2d.org/forum/viewtopic.php?t=706