Having separated out landships as a new kind of construction, it was time to start figuring out how to draw their wheels and legs.
In the case of wheels, this was relatively simple: modules can have a number of wheels attached, and the wheels automatically position themselves to rest on the ground. You can see this more or less working:
In the case of legs, things were more complicated. The basic idea I hit upon was this: each leg would move in turn, and its tip (foot) would describe a motion where it would first go straight up, then straight across, then straight down again, making a careful and mechanical step. A leg would be composed of two parts of equal length, with a joint at the "hip" and at the "knee". Calculating backwards from where the tip needed to be would yield the rotation of both parts.
The result - it walks:
This is the point at which a less experienced programmer would be liable to think that they're nearly done. Landships are a category of construction, they can move, and their wheels and limbs animate pretty much correctly. Well...
Turns out that all kinds of weird things happen as soon as the ground is not entirely flat. I know I am nowhere near done. Here is a partial list of everything I know I still need to do:
- Decrease landships' collision wariness. They keep on thinking they're about to ram the ground and stop.
- Decrease ground collision damage: minor bumps and scrapes are doing serious harm.
- Put in real wheel graphics and rotate the wheels when they're in contact with the ground.
- Put in real leg graphics.
- Constrain leg joints to have a forwards- or backwards-facing knee.
- Unify springs with legs/wheels so that landships are no longer mysteriously held aloft by invisible springs while their wheels or legs are off the ground.
- Improve leg animation to take more time lifting the leg than putting it down, and accelerate/decelerate leg movements.
- Position legs correctly during setup.
- Stop moving legs when the ship isn't moving.
- Correctly pick out new leg spots when moving backwards or being flipped.
- Look for the most suitable leg spot within a certain distance of the optimal position.
- Add translation values for all the new landship-related stuff.
And after all that, a naive programmer might think they're done. In reality, that's at best the halfway point. Dozens of additional smaller things will have cropped up. Still, I'm pleased: the basics have been pretty straightforward to put in, and landships is half of the new feature development for dev 7, so there's hope the next major version won't take all that long!
Join me next time to see what things look like as I start going through that list.