Bruiser V1. A walking machine modelled by a script, then given streets to defend against tanks, helicopters and rival machines
It opens on its own page. About 2.5 MB to load. You drive with the keyboard and aim with the mouse.It opens on its own page, with a stick and buttons to drive it. About 2.5 MB to load.
What it is
A small game that runs in the browser. You drive Bruiser, a six-metre walking machine, through a few blocks of a city laid out like New York at night. Tanks, helicopters and other machines like it come at you in waves, each wave bigger than the last, until your armour runs out.
It started as an experiment in making something walk without animating it. The city, the enemies and the score came afterwards, one request at a time. This is the first version.
How the mech was made
It began with a reference sheet: one machine drawn from the front, back, both sides, top and bottom. My first sheet turned out to be far too close to the machines of an existing tabletop game, so I scrapped it and made a design of my own: squat, olive drab, with orange panels and hazard stripes, sloped shoulder hoods, two short exhaust stacks, a rotary cannon on one arm and an energy rifle on the other.
The model is built in Blender, but not by hand. A Python script makes every piece from boxes, cylinders and extruded outlines, bevels them, and saves the file. Change a number in the script and the whole machine is rebuilt in a few seconds. To check the shape, the script renders the model from the same six directions as the sheet and lays each render half-and-half over the drawing, so anything out of place shows at once.
It comes out as eleven rigid pieces with about 37,000 triangles: a pelvis, a hull that turns on it, two arms, the cannon's barrels, and a thigh, shin and foot for each leg. Each piece has its origin at its joint, so the game only has to turn it. The whole model is a 1.1 MB file.
Walking without animation
Nothing on the mech is keyframed. Each frame the game decides where the two feet should be, and the legs are solved to reach them: with a thigh and a shin of fixed length there is only one place the knee can go. The body is then carried over the feet, bobbing and swaying with the stride.
A foot stays planted until its turn comes, then lifts and comes down where it will be wanted half-way through its next turn on the ground. Running is the same rule with a longer stride and more time in the air. Jumping, falling and landing are a spring: the legs give under the weight and push back. Because the feet look up the height of the ground, it steps up kerbs on its own.
The paint is not in the model. The Blender file has plain colours, and the page lays its own worn paint, grime and bare metal over each part by name. The sound is made in the page too, from tones and filtered noise.
Building the city
The streets are three avenues and four cross streets, with long blocks between them as in Manhattan. Every building, lamp post, fire escape, water tank and container is a flat-sided shape generated in code and heaped into a handful of meshes, so the whole city draws in a few calls.
There are no texture files. The walls' own shader works out the brick courses, the mortar, the grime and every window from where each point of the wall is: the frame, the glazing bars, the sill, and for a lit window the room behind it, with a lamp, curtains and a blind part-way down. The tarmac, the paving and the shop signs are drawn onto canvases when the page loads.
It was too easy to be caught in the open, so each middle block has an alley through it and there are containers stacked at the roadside. Nothing sees or shoots through either.
The enemies and the fight
The tank and the helicopter come from the same Blender script as the mech. The rival machines are the mech's own model again, a little smaller, in grey and red. Each enemy's pieces are baked down to two meshes, paint and lamps, so a dozen of them cost little to draw.
They all find their way the same way: along the roads, corner to corner, until they share a road with you and can see you. Then they stand off and fire. Tanks lead their shells to where you will be; helicopters hang low over the street and slide from side to side. If you go up an alley they can't follow, so they come to its mouth instead.
Around that is a small game: armour, a score, waves, armour packs that a destroyed enemy sometimes leaves behind, marks at the edge of the screen for whatever is out of sight, and a best score kept in your browser.
What I learned
- Start from your own design. A reference that leans on someone else's world has to be thrown away sooner or later. Throwing it away on day one cost nothing.
- A model made by a script can be checked. Laying each render over the drawing found mistakes my eye had passed, such as shoulders that were boxes where the sheet had sloped hoods.
- Rules walk better than keyframes. One rule for where a foot goes gave walking, running, turning, sidestepping, kerbs and landings, with no animation to blend between.
- A camera behind a big machine hides what it is aiming at. Moving the camera to look past its shoulder fixed that; inside an alley it has to come in close, and that is still the weakest view.
- Windows drawn by a shader shimmer in the distance. Far off, a window is smaller than a pixel, so its light has to be spread across the wall instead of being drawn.
- Somewhere to hide needs an answer. With alleys the enemies simply lost you and waited at a corner for ever. They needed a rule of their own for what to do when you disappear.
- It hasn't been played enough. The balance is a first guess, and I haven't yet measured how it runs on a phone.