Build Your Own Game Boy Game, Part 2: How the Game Boy Thinks
- Marcel Pflug
- Apr 4
- 4 min read
Updated: Jul 4
In Part 1 we set up GBDK-2020 and got a first ROM running, with a short message printed on screen. That printed text was a gentle shortcut. To build an actual game like Snake, we need to draw our own graphics, and for that we first have to understand how the Game Boy puts anything on screen at all. It is genuinely different from a modern computer, and once it clicks, the rest of the series becomes much easier.
Understanding Game Boy Graphics
The Game Boy screen is 160 pixels wide and 144 pixels tall. You might expect to draw by setting those pixels one by one, the way you would on a modern screen. The Game Boy almost never works that way. In 1989 there simply was not enough memory to hold a full picture of the screen and update it many times a second. So Nintendo's engineers used a clever trick that defines Game Boy graphics to this day: instead of pixels, the console thinks in small reusable tiles.
A Screen Made of Tiles
A tile is a tiny square image, 8 pixels by 8 pixels. You design a small set of these tiles once, and the Game Boy stores them in its video memory. The screen is then treated as a grid of these tiles, 20 tiles across and 18 tiles down. To draw something, you do not paint pixels; you tell the console which tile to show in which grid cell. A brick wall, a patch of grass, a letter of text: each is just an 8 by 8 tile, placed again and again wherever it is needed. This is why so many classic Game Boy games have that charming, blocky, grid-aligned look.
Four Shades of Green
The original DMG-01 cannot show colour. Every pixel is one of just four shades, rendered in that famous pea-green tint. When you design a tile, each of its 64 pixels is set to one of those four shades: think of them as white, light grey, dark grey and black. Behind the scenes each tile is stored in 16 bytes, using two bits per pixel to pick one of the four shades. You do not have to do that maths by hand, but it helps to know why graphics data looks the way it does when we start defining our own tiles in the next part.
The Background Layer
The grid of tiles we have been describing is called the background layer. It is the main canvas of most Game Boy games. GBDK-2020 gives us simple functions to work with it. One function loads your tile images into video memory, and another places a particular tile at a chosen grid position. Placing a tile is as easy as naming a column, a row and a tile number, like this:
set_bkg_tile_xy(5, 5, 1); // put tile number 1 at column 5, row 5Do not let the punctuation put you off. set_bkg_tile_xy is a ready-made GBDK instruction, and its name reads as set background tile, by x and y. The three numbers in the brackets simply answer where and what: the first is the column, the second is the row, and the third is which tile to place there. So this whole line says put tile number 1 into the cell at column 5, row 5. Change the three numbers and you move the tile anywhere on the grid. Almost everything we draw from here on is just this one instruction, repeated with different numbers.
That single line is the heart of how we will draw everything in Snake. The whole game is really just deciding which tiles to place, and where, many times a second.
Sprites: Things That Move Freely
There is a second way to draw, and it is the one most people picture when they think of game characters. Sprites are small images, again built from 8 by 8 tiles, but unlike the background they can be positioned anywhere on screen, down to the individual pixel, and moved smoothly. Mario, a bouncing ball or a blinking cursor are all sprites. The catch is that the Game Boy can only show a limited number of them at once, 40 in total, and only a handful on any single horizontal line. Sprites are perfect for a hero that glides around, but less suited to something that grows without limit.
Why Snake Lives on the Background
This is exactly why we will build Snake out of background tiles rather than sprites. A snake grows longer and longer as it eats, and could easily pass the 40-sprite limit. It also moves on a neat grid, one step at a time, which fits the tile system perfectly. So our plan is simple and robust: we will design a handful of tiles, one for the snake's body, one for the food and one for the wall, and then play the entire game by placing and removing those tiles on the background grid. No flicker, no sprite limits, just clean and reliable drawing.

The four tiles we need for our little game:
Empty – empty light-colored area (background)
Wall – solid dark square (wall)
Food – dark diamond on a light background (food)
Body – solid dark square (snake's body)
Coming Up in Part 3
Now that we know the Game Boy thinks in tiles, it is time to make some. In Part 3 we will design our own tile graphics in code, load them into the console and draw the Snake playfield, complete with a wall around the edge. From there, the game starts to take shape quickly.
If you would like to see the hardware behind all this theory, the original DMG-01 console in the collection is the very machine whose tile-based screen we are learning to command.










Comments