Book Reviews

My views about what I read, often programming slanted.

31

DEC
2014

Game Programming Patterns

I meet a lot of programmers that tell me they got started because they wanted to build games. However, when I ask most of them which games they have built, the list rarely includes anything more than mostly unplayable toy projects.

I can only guess at the reasons for this oddity, but I suspect it might be due to the fact that games are fairly complex. Even if you want to rebuild a fairly simple classic like Space Invaders or Snake you need to know at least a little about event loops, keyboard handling, animation, and collision detection. If your day job involves a different kind of programming, like Web application development, odds are good that you don't get a lot of practice with these concepts.

That may not be your story, but it was definitely mine. This year I decided that it was finally time to learn how to build games. I used several sources to gain this knowledge and some helped more than others, but the biggest win by far was a book called Game Programming Patterns by Bob Nystrom.

The idea behind this book is very similar to the beloved Patterns of Enterprise Application Architecture: focus in on a specific kind of programming, games in this case, and work through each of the patterns that are must haves for that domain. The patterns receive fairly typical coverage here including discussions of the problem the pattern solves, an example implementation, gotchas to watch out for, and common variations you may run into. There's also a great range of patterns from simple but helpful tips to meaty key concepts and on into some nitty gritty optimizations. This comes off without a hitch and I can confidently say that this book taught me the technical side of building games.

But that description way undersells the book.

It probably doesn't surprise you to hear that a book about game patterns does a good job showing you how to build games. The truth is though, that it just does a great job of teaching you these patterns, games aside. While there have been some epic attempts to codify huge chunks of patterns, like the very famous Design Patterns book, I feel books like Game Programming Patterns and Patterns of Enterprise Application Architecture are far more approachable. They have the unfair advantage of context. Seeing how a handful of patterns interact to solve a specific problem really helps you see which parts do what. So the fact is that this book can teach you how to build games if you have any interest. Even if you're not that into the subject though, this is probably still a pretty darn good book to read. There are patterns in here that do apply to Web application development, like Event Queue, Service Locator, and Dirty Flag, and this book sure makes them easy to pick up.

And I'm still underselling this book!

It would be very hard to overstate the small touches at play here. The author has said this book took years to craft and I totally believe it. The content feels so well put together. Patterns reference other patterns, inside this book and out, and it really feels like they've been boiled down to just the bits you need to know. Plus the writing is superb, with a laugh-out-loud great sense of humor. There's one point in the book where a way over the top metaphor is used to describe CPU caching and you realize, as you're cracking up, that it's probably the best darn description of the concept you will ever read. And that's just one example of many. I was so addicted to this book that I read some chapters off the Web site using my iPod and it was still a great experience. Let me say that one more time so it sinks in: there's a free Web version of this programming book filled with code that's gorgeous even on an iPod. How many times have you ever been able to say that? (It's definitely a first for me.) In fact, you may just fall in love with the Web version, and the author has thought of that:

If you want to give me money, but don’t actually want a physical book,
consider giving it to a friend or your local library. I get money, you feel
good, and someone gets a free book!

Those are words of wisdom we should all follow.

When you're done geeking out over this book, you can still get more gamey goodness from the author's blog. It's equally awesome. For example, have a look at this post with interactive simulations built right into the article.

OK, I'm done gushing. Please just go throw money at this author now in the hopes that he will write more.

Comments (1)
  1. randito
    randito December 31st, 2014 Reply Link

    Sold.

    Got my dead tree copy coming from Amazon. Thanks for the review and pointer to the book.

    I'm kind of partial to this book, too. It's for Python but the concepts are totally valid => http://www.amazon.com/Programming-Python-Charles-River-Development/dp/1584502584/ref=sr_1_7?ie=UTF8&qid=1420050995&sr=8-7&keywords=python+gaming

    1. Reply (using GitHub Flavored Markdown)

      Comments on this blog are moderated. Spam is removed, formatting is fixed, and there's a zero tolerance policy on intolerance.

      Ajax loader
Leave a Comment (using GitHub Flavored Markdown)

Comments on this blog are moderated. Spam is removed, formatting is fixed, and there's a zero tolerance policy on intolerance.

Ajax loader