It seems just about every game these days relies on physics. There are many engines available but probably the most popular is Box2D, which powers smash hits including Angry Birds and Tiny Wings. But if you’re looking to write your first physics based game then it can all feel rather daunting. Thankfully Packt Publishing’s latest book, Box2D for Flash Games, is aimed firmly at ActionScript 3 programmers looking to take their first steps with Box2D.
Intended as an introduction to Box2D, author Emanuele Feronato does a great job of guiding you through the fundamentals, relating each new concept to a handful of real-world games. Throughout the course of the book he’ll unlock the secrets of two popular games in particular: Angry Birds and Totem Destroyer. In fact Emanuele goes one step further, by leading you through the steps to actually create clones of each game. You’d be surprised at just how easy much of it is.
The first chapter will have you up and running relatively quickly, with Box2D installed and your first physics world running within Flash. By the end of the second chapter you’ll be adding content to your world and viewing your creation via Box2D’s debug drawing mode. The third shows you how to interact with your content and has you write a simple version of Totem Destroyer, making use of mouse interaction to remove physics bodies from the game world. By this point you’ll start to appreciate the possibilities that Box2D opens up to you as a games developer.
As you progress, the book addresses more advanced topics including applying forces, collision detection, joints, and motors. Everything is handled in a clear, straight forward manner, with simple code examples being used to cement each new concept. With the knowledge gained from these chapters not only will you have improved your Totem Destroyer clone but you will also have learned how to build the first level from Angry Birds!
The final two chapters are relatively short and tie up some loose ends. First you’ll learn how to replace Box2D’s debug graphics with your own custom artwork, before finishing up with some additional points regarding collision detection.
Spanning only eight chapters and coming in at under 200 pages in length, Box2D for Flash Games is a relatively quick read. In fact the book does seem to end rather abruptly but it does do exactly what it promises to do, which is provide a solid introduction to Box2D. Plus, unlike most books, it does this without the reader having to invest too much time. I was genuinely surprised and impressed by the number of practical examples the author manages to cram into such a short space.
There are a few other things worth noting. Although the book focusses on ActionScript development, it assumes the reader is using Flash Professional. If you use Flash Builder or some other alternative IDE then you should be able to get things up and running relatively easily, but its worth noting that you’ll be on your own. Also, while the Angry Birds and Totem Destroyer genres are covered, it would have been nice if some other popular game concepts were explored including endless runners such as Canabalt and simple 2D driving games like Hill Climb Racing.
These really are just minor gripes however. Box2D for Flash Games does an excellent job of introducing the reader to the exciting world of 2D physics engines. By the book’s end you’ll be in a position to start developing your own physics-based games with your new found knowledge. A highly recommended read.