Drawing a game with code

Every pixel in tennisBOP is drawn by code. There are no image files for the courts, the players or the scenery. This post is about how that works and why.
One frame, one palette
The game draws into a single frame 384 pixels wide and 216 tall, then scales it up to fit your screen. Every pixel in that frame is a number pointing at one palette, 61 colours arranged in ramps by material: clay, grass, skin, kit, sky.
Working this way makes rules checkable. The ball has to stand out against everything behind it, so contrast is measured, not eyeballed: the ball against the dark windscreen is 11 to 1, and court lines against clay are 3.5 to 1. Every backdrop colour is deliberately duller than the court, the players and the ball, so your eye goes where the action is.
Four venues
Camps Bay is home: the Twelve Apostles, the Atlantic, palms, a small grandstand and a golden-hour light behind the title screen. Riviera is a villa club on the lakes. The Garden is an English lawn with a clubhouse clock and mowing stripes drawn in perspective. The Marina is a hard court by the sea, blue inside and green outside.
The big design passes, the palette and the player body, started with three competing proposals, judged on readability, art direction and palette discipline, before the best ideas were merged. An automatic checker verifies every venue, down to making sure no pixel is left unpainted.
Five players, twelve clips
The players are hand-placed pixels: 24 by 34 seen from behind for whoever plays at the bottom, 18 by 22 face-on for the far side. The five characters share one body and differ only in colours and hair. A headband, a cap, a ponytail, a visor and a short cut are enough to tell them apart at a glance.
Each body has twelve animations: idle, run, forehand, two-handed backhand, slice, lob, lunge, volley, smash, serve, a celebration and a slump. The game reads where the ball will be met and picks the right clip before the swing starts, so the racket arrives on the frame the ball does.
Because the art is code, the design workspace and the game run the same drawing functions. A mockup and the real game are pixel-identical, so what gets approved is exactly what ships.