Saturday, August 8, 2009


The simple task of "add physics to Closure!!1!1" turns out to be not so simple after all. Currently I only have balls in the game, implemented with my own hacky physics system (as in I wrote it in 1.5 days just so I could "have something in the game, I'll fix it later". I'm mostly typing this out as a way to organize my thoughts, a lot of programmers do that.

I have a really easy way of telling if a point is lit up, I simply look up the color of the light on that pixel (light is a small texture upscaled with bilinear filtering, I take this into account). In the new game, it is more than simply circles. I use a bunch of textures, blurring, and odd shapes (including spotlights) to create a good looking light texture, and describing it via geometric shapes is near impossible to do in real time.

The land is triangles, but currently for purposes of speed I have it save a collision map so I can use bitmap collision. I compare the level with the light to determine if a point is colliding.

I suppose I'm gonna have to fall back to hacking my ball collision into box2D, then constructing the box out of 14 or more connected balls along the perimeter

I can estimate surface normals this way too, and indeed I use that for my hacked ball physics.

Unfortunately adding box physics keeps haunting me as there doesn't seem to be a simple or speedy way to do so.

I'm considering this option right now. I can use an existing engine like Box2D.

Subdivide my shapes into these formations:

Turn off collision for segments not in light:

I have the level stored as triangles anyway.

This would make the raw detection portion similar to my current method of "check points around the perimeter" but would offload that to the physics engine.

Crud though as I type this I realize its flaws. That's why I'm typing it out I guess, to organize my thoughts here. If an object is inside a land triangle when it is turned on, it will resolve out of the triangle, whether lit or not, when in reality, if the light bisects one of the land triangles, I only want it to resolve out of the lit portion of the triangle.

A predicament

I suppose I may have to resort to hacking my ball collision into an engine such as Box2D, then constructing a square out of a bunch of small balls (for collision with the land) and one large square (for collision with other boxes and balls).


Blogger Adam DeLine said...

I really don't understand programming, so what your saying doesn't make a lot of sense to me but its very intriguing. your game sounds like its going to be pretty amazing. the screen shot on NG looks awesome. keep the flathead as an unlockable character or something.
i love unlocking secret things.
good luck with the work you have left, cant wait to see it.

August 17, 2009 at 11:49 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home