DEV Community

Ant Games
Ant Games

Posted on Fully Autonomous

Designing a 3D spaceship builder game in the browser: hull cells, part placement and two limit bars

WARSHIP WORKSHOP: two 3D warships exchange fire above a planet

Play WARSHIP WORKSHOP free in your browser. It is a 3D spaceship builder game and space auto battler: you shape a hull, add guns, shields and engines, press FIGHT, and watch your ship battle an AI rival on its own. This post is about the design of the builder itself, because in a game where you cannot steer during the fight, the build screen is the whole game.

A note on how it was made: the game was built with AI coding tools, directed and checked by our team at Ant Games. It is free, there is no pay to win, there is no sign-up, and it plays in the browser with nothing to install.

Why the builder carries the game

In most space games the ship is a thing you fly. Here it is a thing you write. After you press FIGHT you take your hands off, so every decision you make happens before the first shot. That sets a high bar for the build screen: it has to be quick enough that trying ten variants feels fine, and clear enough that you can see why a variant lost.

We ended up with three ideas: the hull is made of cells you can paint, parts snap to cells and can be turned, and two bars limit what you may add.

Idea 1: a hull made of cells

The game has 20 hulls, unlocked with credits earned by fighting. Each hull starts as a stock shape. If you want something else, press SHAPE (or H) and paint or cut cells to change the outline. The 3D ship updates as you drag.

Three small tools keep this from becoming tedious:

  • Mirror (M) paints both sides at once, because most ships you would draw are symmetrical.
  • Undo (Ctrl+Z, or U) and redo (Ctrl+Y) make a bad stroke free.
  • Reset hull brings back the stock shape, so experiments cannot ruin a good base.

A hull defined as a set of grid cells is easy to reason about. Here is the idea as a sketch we wrote for this post, not code from the game:

// a hull is a set of "x,y" cells; mirroring reflects across the centre line
function paint(hull, x, y, mirror, width) {
  hull.add(x + "," + y);
  if (mirror) hull.add((width - 1 - x) + "," + y);
}
Enter fullscreen mode Exit fullscreen mode

Undo then only needs to remember each stroke as a list of cells added or removed.

Idea 2: parts that snap to cells, and can turn

There are 500 parts. You drag one onto the deck, or on a touch screen tap the part and then a cell. Guns, shields and engines can be turned by 90 degrees (R, or the TURN button), and engines can go on any cell, which is where a lot of the fun is: an engine pointing the wrong way is a design mistake you can see.

To make that readable, the workshop draws a live flight course line for your ship, and after a fight it shows LAST FIGHT HITS, a record of where you were hit. Those two aids turn a loss into a lesson: the course line says where the ship will go, and the hit list says what to armour next. A part can be removed by right-click, Delete, or by dragging it back to the tray.

You can also orbit and zoom the 3D view (drag, Q/E, scroll, or a two-finger pinch), because a ship that looks fine from the front may leave a gun with no clear shot from the side.

Idea 3: two bars, not a hundred rules

Free-form building needs limits, or the best ship is just the biggest one. We use two bars: BUDGET and POWER. You must stay inside both. A ship with no reactor, or with no working gun, is out, and at 90 seconds the less damaged ship wins. That is the whole rule set the player has to learn.

The AI rivals are built to your budget, and the exact budget line is shown on every match. We prefer showing the line to hiding it: if a loss comes from being outspent, you can see that, and if it comes from a poor layout, you know that too. Six ranked tiers run from a budget of 440 up to 5,200, and nothing in them is sold: credits come from fighting and unlock parts.

Keeping iteration fast

Because the builder is the game, we put effort into the loop around it:

  • Save up to 30 ships per tier in MY SHIPS, and load, rename or delete them later.
  • Replay any fight, and pause to step through every part on both ships.
  • AUTO fights run with parts you already own, so you can test a build without playing the match by hand.
  • Fights last at most 90 seconds, at 1x, 2x or 4x speed (keys 1, 2, 4).

What we would tell another builder-game maker

Make the hull editor forgiving (undo and mirror first), make the consequences of a placement visible before the fight (the course line), and make the loss readable after it (the hit list). A builder game lives on the question "what should I change?", and every screen should help answer it.

Try it

Build a ship and press FIGHT. It is free, with no account, and the 3D builder runs in the page. If you make a ship you like, save it and see how far up the tiers it gets.

Top comments (0)