Thursday, 28 October 2010

AdvancED Game Design with Flash – Book Review

Lovely, lovely Friends of ED were kind enough to send me a copy of AdvancED Game Design with Flash by Rex Van Der Spuy. Just because they gave me free stuff, it doesn’t mean I’m going to give this book an easy ride though! This book has lots of good things and a few not so good things, as I will describe.

Let’s start by getting one thing out of the way – this book has almost nothing to do with game design. There is no mention of game design (as I understand the term) until Chapter 7, where Rex gives a few pages of good advice. The other 700 or so pages of the book are about game programming/development/architecture. (To be clear, my understanding of "game design" is: deciding what happens in your game and tuning the game mechanics to make them fun).

The best thing about this book is that it is very comprehensive, covering pretty much every hurdle you will meet when building a Flash game, including an extensive looks at collision detection, which is probably one of the hardest parts of game development if you aren’t using an engine like Unity3D, Box2D or Flixel. There is an explanation of many alternative methods such as bitmap collisions (including destructible bitmaps!), axis-aligned bounding box (AABB), circle, line and “separating axis theorem” for more complex shapes. It also shows you how to do “spatial hashing” which is a “broad-phase” technique for reducing the number of collision checks you need to do, which is very useful. Unfortunately it doesn’t include the “quad-tree” technique, which is the one I need to get my head around at the moment.

Another section you may find useful is the analysis of blitting. I think the benefits of blitting are a bit exaggerated, but this book takes a very even-handed approach, explaining when they will be useful and when they won’t. It also includes some benchmarks and shows you how to make your own, which you should ALWAYS do if you are making “optimisations”. Don’t believe a word that Rex, myself or anyone else tells you about optimisation without testing it yourself!

I’m not a huge fan of how the author organises his code. He’s gone for an MVC approach throughout the book, and even though this is a road I’ve been down myself many times, it’s not one that I would currently recommend (for the record, I favour a game object composition approach like you get in Unity3D). In general the code style is decent, with well named variables and plenty of comments. There are some places where the code could have been made both faster and more readable by greater type safety and less use of the dynamic properties on objects, movieclips and arrays. There are some places where variables are not well-named, for example calling a function “ln()” rather than “leftNormal()”. In the age of auto-completion there is really no need for abbreviated function names, but this book is by a long way not the only place you will find them.

Here is my most major criticism the book: for physics/movement Rex is using his own vector and “verlet” techniques, and I am dubious about both. I’m not an expert on integrators, but I’m very skeptical that Rex’s approach really is verlet at all. It seems to me that he’s using the standard Euler technique that most Flash developers use, but just storing his data in a different way. I would love to be wrong about this one, so if anyone has read the book and has a good understanding of verlet, please leave a comment. The vector class the book uses is also non-standard. The usual implementation of a vector has just an x and y position, and some methods to manipulate it such as add, multiply, divide, rotate, dot-product etc. The book’s vector class has these methods, but it stores two sets of x and y values – a start point and an end point. It all still works fine, it’s just not how it’s normally done.

On points like this I find it very difficult to draw the line between what is just differences in style and what would be considered “best practice”. As I already knew most of the information covered in the book it’s easy for me to worry too much about things I just do a bit differently. If you have never used these techniques, any implementation will be very useful to know. Ultimately, if it gets the job done, then it’s fine, and Rex’s implementation definitely gets the job done.

Some other useful explanations in the book include playing sounds, pathfinding (including a really good explanation of A*) and a full tile-based platform game engine. After my talk at Flash on the beach I had many requests for my source code, but as all my demos were built on my non-open-source game engine, I couldn’t share them. I would happily recommend this book to any of those people as it includes the vast majority of the code you need to make any of the demos I showed, including driving games and platform games.

Overall, I think that if want to do some more advanced Flash games and you don’t know where to start, this book would be a great place.


9 comments:

MC said...

Can you explain what do you understand by "game design" and whats the difference with programming/development/architecture?
Regards

Laxity said...

I read the Foundation Game Design by Rex and found it a great starting point.
Will check this out after reading your review.

Iain said...

MC, game design is something like: deciding what happens in your game and tuning the game mechanics to make them fun. It's a separate thing to programming the game engine.

I have updated the post with this definition.

jansensan said...

I would like to know why you don't suggest an MVC approach to game development? I have not done extensive game dev (would love to tho), and what I do I do use MVC and it helps. I would love to know where it falls short, what you think are better approaches, etc.

jocuri noi said...

i adore write, segure boockmark it!

Jocuri said...

Well, is that book anygood, does it give good examples or you have to search the net for them, and they only explain the functions.

Menashe said...

Wow. What an awful review. The purpose of a game programming book is to guide fledgling game programmers along the journey they will take in learning their hobby/occupation. As a pedagogue- a mentor paving a path for students and teaching how to avoid the obstacles- this book is incredible. I learned how to make games from both of Rex's books. You didn't address his writing style, his ability to teach, and his progression from fundamentals to specific techniques. You nit-picked about little details that wouldn't give readers any clue as to whether they will learn game programming from this book. Sorry, but you have lost any credit in my mind.

Iain said...

@Menashe

"Overall, I think that if want to do some more advanced Flash games and you don’t know where to start, this book would be a great place."

I think that's a pretty good recommendation, regardless of the other things that bothered me about the book. But things like how they handle Vectors etc - they're just wrong, and that's not my opinion, it's a fact.

Gayan said...

I do agree with Menashe. I guess you're skimming over chapters and not really reading them. I'd love to know your preferred design patter for organizing the code.