My Lacuna-based board game will be a tile placement game where all the
players work together cooperatively to fend off an alien invasion.

Let's Get To The Perl Already!

There are several great image manipulation libraries on the CPAN, but my
personal favorite is Image::Magick.
I started by creating a base image which I could manipulate in any way that I
wanted. (I based my choice off of The Game Crafter's
list of component sizes and prices.) I decided to use mini
cards, because the table would fill up too quickly with full
poker-sized cards; there'll be a lot of cards on the table!

Note that I used say in front of the ReadImage call.
Image::Magick will emit a textual exception on each call if
anything goes wrong. I could easily wrap that with better error handling, but
for now printing to the screen is sufficient for my needs.

When printing things (really printing them, with ink and all) you
also have to take into account something called bleed and cut lines. It's easy to
draw the cut line on the card in red as the boundary of the printable image
content.

So far so good. The next step is to give this card a background so that it
starts to look like a card. For this I'll take one of the planet surface images
from the Lacuna Expanse and rotate it and stretch it to fit the shape of the
card.

Note the exclamation point (!) on the Resize
command. That tells Image::Magick to distort the native aspect
ratio of the image. In other words, stretch the image to fill the size I've
specified.

You may have noticed that this image looks enormous. That's because it's for
print (on paper!) rather than screens. Print has more pixels per
inch/centimeter than screens, thus the image looks bigger when you
display it on a screen.

Now the card needs a title. Adding text to the image is straightforward.

Now we're finally getting somewhere! This is really starting to look like a
card. Use the same technique to overlay an icon onto the card. As in so many
games, these icons symbolize an ability that the card grants the player who
uses it. You can get free icons from all over the web; one of my favorite
libraries is Glyphish.

A game like this wouldn't be very interesting if you could place any card
anywhere you want. To solve this, I want to to add something to the card to
indicate how other cards can connect to it. This is the most challenging part
yet, because I want to make a half-circle/half-rectangle connector. Because
this is a bit more complicated and I want to use it for drawing connection
points on various sides of the card, I'll turn it into a subroutine.

Sometimes it's nice to give players hints about stuff so they can form
better strategies. To that end, I added a series of pips above the title to
indicate how many copies of this card are in the deck. In this case, this card
is unique.

Rationale

Now that I've shown you how to create a card, you may have one question. Why
would you go through the work of coding it rather than just using Photoshop or
the Gimp? There are lots of reasons to code it including things like you don't
know how to use image editors. However the really important reason is the same
reason you write code to do anything... automation! A game isn't made of just
one card. Likewise, games aren't designed in just one try. It takes lots of
play testing and revisions. If you design your board game using code you can
whip out a new revision as easily as changing a config file.

Of course, automatic image generation isn't only for games....

Next Time

I've shown you how to create the images for a game. If you're like me, the
next thing you want to do is print your game. You could do this at home, but it
will cost you a lot of time and money (ink jet ink costs more than human
blood). You could take it to Kinkos, but you won't get a nice quality product
because they don't specialize in making games. Instead, you can upload your
files to The Game Crafter, where
you'll get a custom game that looks like it game from the game store. There's a
nice easy to use web interface to do this, but you're a Perl programmer. Why do
something manually if you can automate it?

Besides that, it's a real-world example of interacting with a web service
written completely in Perl—on both sides. Who wouldn't be interested in
that?