How TETERI is built

One Layout Engine, Four Shapes

Solo widescreen, solo portrait, split screen and a focus view, all produced by the same function.

The game has to work on a 4K monitor, a phone in portrait, a phone in landscape, and a split screen with two boards. Rather than four code paths, there is one function that computes slots.

What a slot is

A slot describes one player's playfield: the cell size, the well's position and dimensions, and the rectangles for the hold panel, next queue and stats.

Every drawing function takes a slot. Nothing downstream knows whether it is rendering a solo run, the left half of a duel, or a shrunken opponent board.

The four shapes

Solo widescreen. Hold and stats to the left, next queue to the right, well centred. Used when there is horizontal room.

Solo portrait. Hold and next as a strip above the well, stats in a line, the well taking the rest.

Versus split. Two equal slots side by side with a centre column carrying the match clock and running score.

Versus focus. Your well at full size with the opponent's at half scale beside it, floors aligned so stack heights compare directly. Used when there is not enough width for two full boards.

Choosing between them

Available width and height, after subtracting whatever the on-screen controls occupy. Each shape has a target aspect ratio, and the cell size is the minimum of what the width and height allow.

The landscape problem

The subtlety is that the on-screen controls do not always eat the same axis. A bar across the bottom costs height; thumb clusters at the edges cost width.

On a landscape phone, reserving 128 pixels of height for a control bar left cell sizes around ten pixels — unplayable. Moving the controls to the sides and taking the reservation from the width instead produced seventeen pixel cells in the same viewport.

That is why the layout function takes a parameter describing where the pad is, rather than assuming.

PLAY TETERI ALL ARTICLES