As discussed in both Part 1 and used in Part 2, the Game Boy has a limited amount of graphical storage. You can only have 256 tiles of 8×8 pixels. This limits what you can do and, more importantly, dictates how you compose tiles on the screen as a result.
However, as glossed over in Part 2 and now explained in Part 3, you can generate the tiles and maps themselves using two sets of tools GBTD and GBMB.
Game Boy Tile Designer
Found here, the Game Boy Tile Designer will be your very best friend when it comes to create and exporting tiles. Beyond simply allowing you to design — hence the word in the title — tiles, it also allows you to copy them from one slot to another and, most importantly, uses functionality called “Split Paste” to paste content from another image program into 8×8 tiles.
For example, for Part 2, I used the following set of tiles I developed in another program. From there, I selected the whole image and copied it into the Windows clipboard.
In GBTD, go to Edit -> Split Paste.
Now, all of the tiles have been arranged as an increasing set starting from what position was selected from the right-hand side. (In this case, the first, 0, position.)
Once that is done, it is a matter of “including” them in a Game Boy program. To do that, go to File -> Export To.
On the next screen, click on the drop-down menu and choose the “GBDK C file (*.c)” option.
Select “Browse” to find the location and give the file a name. As well, change the label to something useful and finally, as a last step, set the number of tiles to export in total in the “From” field. (In this example, it is 47 tiles.)
Once exported, the “alpha” tile set will look much like the “alpha.c” file from Part 2.
Note: The above, pasting and exporting, were the exact steps I performed to generate the files for Part 2.
Once exported, be sure to File -> Save the set as “alpha.gbr”. (The result will be used in the next step and will allow you, when re-opening the file, to use File-> Export in the future, or simply Ctrl-E as a shortcut to update the file.)
Game Boy Map Builder
Like with GBTD, the GBMB can also be found on the same site.
GBTD and GBMB are created to feed into one another. The files saved from GBTD can be opened by GBMB to use the tile to create larger ‘maps’ of areas or as part of the creation of a meta-sprite, a sprite made up of multiple tiles.
In our example, go to File -> Map Properties and select the file created in GBTD, “alpha.gbr”
When asked for width and height, use 10×2.
In GBMB, the left-click is used to select a tile from the right-hand list of perform an action from the left-hand listing. Right-clicking places a tile on the map.
Continuing from the discussion from Part 2, we can use the fact that tile 48 is ‘blank’ to use it as a way to make the map ‘blank’ to start.
Then, using one letter at a time, we can write “HELLO WORLD” on the map.
Once we have the map arranged as we like, we can export the map like in GBTD through the File -> “Export to…” option.
Also like in GBTD, select the “GBDK C file (*.c)” option, use “Browse” to set a location and name, and set a label.
Unlike in GBTD, click on the “Location format” tab and set “1 plane (8 bits)” and, in the properties, select “Tile number” from the drop-down menu. Once done, click the “OK” button.
The resulting file, much as “alpha.c” using GBTD was “alpha.c” from Part 2, “helloWorld.c” will be the same except for the addition of the header comment information.
Once exported, be sure to File -> Save the map. This will save you time in re-creating it and, like with GBTD, will remember the location you saved the file and allow for quick File -> Export or Cntl-E exporting.
Unlike Part 1 or Part 2, there are no code changes to “main.c” in this Part. However, it is included here for reference.
Note: The creation of “blankScreen.c” and “sprites.c” are not shown in this post. However, given the techniques explained, their creation, as a 20×18 map of tile 48 and sprites drawn as tiles, is fairly self-explanatory.
In Part 4, I will cover the basics of colliding sprites and project management.