Monday, July 26, 2010

Physics library updates, continued

When I started using the Chipmunk physics simulation library I did what most programmers do when confronted with unfamiliar code: I rewrote it. It was a good way to learn the ins and outs of the code, and it did integrate better with my own code, but ultimately it meant that I wasn't benefiting from other peoples' continued work on the library. The whole point of libraries is to save work.

I've fixed up the current version of the library to work with my compiler (MS Visual C++) again. Scott Lembcke has accepted the patch into the main repository, so hopefully I can save someone else some work. I've also adapted my lunar lander program to work with the updated stock library, so now I should be able to get upgrades much more easily.

The end result, of course, is that the game looks and behaves exactly the same. I have turrets in an initial state; I will now dive in and work on getting them up to fully operational status.

Monday, July 19, 2010

Physics library updates

For my lunar-lander-on-a-disc program I need some intersection-testing functions that were added to the Chipmunk Physics library I'm roughly based on. Since I translated the library from C99 to C++, though, I would need to translate the new code as well. This is a maintenance pain, so this weekend I spent some time trying unsuccessfully to get the stock library into a state in which I could use it.

I like Chipmunk; it's very understandably written and sensibly designed. I'm sure its author Scott Lembcke is reading this. (Hi Scott!) The key problem seems to be that the library is written in C99, a newer dialect of C which is poorly supported by Microsoft's C compiler. Since C99 moves C toward C++ I can get by with relatively small modifications if I compile the C code as if it were C++. Still, since the main library development isn't using my compiler I can expect to have to do this regularly.

As a result I've been examining Box2D some more. It builds easily out of the box, and it's written in C++ so it should mesh better with my project. It has a different approach to collision shapes; I'd need to break down the rocket hull into a set of convex shapes, but that wouldn't be hard. The terrain might be a bit more work. Box2D doesn't support line segments as a collision primitive (although there is contributed code to do so), so I'd probably take the triangulation and merge triangles into polygons up to the 8-vertex limit.

I've got various directions I can go and it's hard to decide how much work I should spend on this. I could patch up my library and continue working on gameplay; that might be the most prudent. Ultimately I want to produce a Flash version of the game, and I think Box2D might give me some help there.

Monday, July 12, 2010

What I'm Reading

I went camping this weekend, so no programming, alas. When I wasn't herding children I worked on my reading research instead.

ThiefRL, when I eventually return to it, will be getting a layer of Chinoiserie. Here's what I've been reading in preparation:


My brother also picked me up some architecture books on his last trip to Shanghai; they're entirely in Chinese though so I can't give the titles.

Fox spirits seem to be similar to the fairies you find in British Isles folklore. Ghosts, on the other hand, are odd; I haven't really gotten a good handle on how they work. I just finished reading a story where a ghost ended up marrying a guy and bearing him a son, so it's not clear exactly how being dead slowed her down. I've read two stories so far where a guy has a three-way with a fox spirit and a ghost; that strikes me as a bit unrealistic, especially if said guy is a shy student with no obvious redeeming qualities.

Apparently the Strange Tales were heavily commented on by “scholars” of the succeeding centuries. The translator has mostly omitted these, but left them in on one story to give a sense of what they're like. The depth of the commentary on that story was similar to what you'd find in the comments section on an Internet article. I kept expecting to see “Firsties!” or “This. So hard.”

Thursday, July 8, 2010

Turrets: First Steps

I've started on implementing some turrets to shoot at the player's rocket.



This is a chance to use my aiming math (here's another explanation from Scott Lembcke with graphs instead of equations). So far I have the turrets aiming without regard for acceleration of any kind. I'm searching for a combination of parameters that will make the player react while still leaving them enough time to do so. I think I will want to make the turrets smart enough to take into account the rocket's acceleration; otherwise it's too easy to dodge them by just flying through with your engine blazing. Maybe there will be different kinds of turrets with different target-leading algorithms; if they're clearly visually different it could be interesting. One would aim to hit the rocket without considering velocity or acceleration; one would aim considering only velocity; and one would aim considering both velocity and acceleration.

Having some additional projectiles is making me realize that my gravity is not very strong. The bullets don't arc much. I don't remember but I think I originally sized the gravity so it would be similar to Earth gravity based on the rough size of the rocket. Just looking at how long it takes to fall its own height when starting from rest (at sea level). After I have the turrets basically working I think I'll do a round of gravity strength experiments. Of course the rocket engine will have to be scaled accordingly; it needs to be able to deliver greater acceleration than gravity at “sea level” (where the gravity is strongest). Scaling gravity up might speed up the gameplay which could be interesting. I have it in my mind to add on-foot movement (a la Star Guard) and wheeled vehicle movement, so the gravity will need to feel OK for those too.

The projectiles need a lot of extra work. They need to go away upon intersection with the rocket, and they need to deliver an impulse and some damage. At the moment they are regular colliding bodies, so they do deliver some impulse and damage but I'd like it to be arbitrarily tunable. I think I will have the bullets “fade out” over time so they deliver less damage as they age, before disappearing entirely.

The turrets need to have their range of motion clamped so they can't shoot into the ground.

I'm weighing whether it's worth it to have my own version of the physics library (I translated it from C to C++) and keep porting vendor drops from the original, or whether I should just write the necessary shims to connect up the C library to my vector class and what-not so I can use it directly. I'm sort of inclining toward the latter. I'm also looking at Box2D again, although I haven't quite figured out how I would translate my collision shapes to their model. They have a maximum of eight vertices per convex shape, I think, so I'd need to make a bunch of shapes to represent my curved surfaces (my game's all about curved surfaces).