Occasionally you get halfway through a book and start thinking to yourself “when is the author going to tell me how to use this technology to create something cool?” With PHP Game Programming, by Matt Rutledge, I had that feeling right up until the last page. I wouldn’t consider myself an expert PHP programmer—not by a long shot—and Rutledge sure knows his onions from years spent as a web developer and database programmer, so as a beginning text to PHP this book is reasonably good. It’s aimed at beginning to intermediate developers interested in broadening their game development skills.
It is the coverage of game programming that causes the book to really fall down. The subject of PHP Game Programming would have been cutting-edge in 1994 when the World Wide Web was a new frontier and “on-line gaming” on the Internet consisted of dynamically generated pages using CGI Perl scripts to maintain the state. Today, the techniques presented are really nothing more than an interesting footnote of how not to create web-based games. Rutledge knows his stuff, but his book is nine years too late. Following the basic introduction to PHP, he develops a couple of HTML games—tic-tac-toe and a simple chess game driven by a non-relational database that stores the possible moves. Once the basics of PHP and HTML are covered, Rutledge moves on to develop “more sophisticated” games, such as an Artillery clone that lets you lob cannonballs at your opponent over a hill by setting elevation and power. A sort of thinking man’s version of “guess the number” that utilizes the third-party GD graphics library to generate images in “real time.” These images are served as each player enters their moves using a standard HTML form. I wrote an Artillery-like game for the unexpanded 2K Acorn Atom in 1978, and it was more interesting than Rutledge’s version. Mine even had animated explosions and sound—more than can be said for the version presented in this book. This isn’t to reflect on either Rutledge’s or my own programming prowess, just an observation of the suitability of the technology used to solve a problem.
In chapter 10, Rutledge demonstrates the use of sockets by creating a persistent server and dedicated client that he later develops this into what he terms a “massively multiplayer online game.” To be honest, though, I would be hard-pressed to consider using PHP to create a persistent server for any game that I expected to support massive numbers of players.
Of the exceedingly few cool features in the book, the section covering dynamic generation of Flash movies certainly stands out as something rather neat. This section provides a reasonable introduction to the concept, but then fails to develop it. Other than learning how to draw a few lines and boxes on the screen, no space is given to developing interesting games or even ideas that use the technique. I can only think of a few uses for this scheme: protecting Flash movies (there are other equally adequate ways of doing this, however) and streaming dynamic content from a database (though the newer versions of Flash include this capability). I’m sure there are some very cool ideas that could make use of this dynamic content generation, it’s a shame the author never explores any of them in the text.
As an introductory text to the PHP language, PHP Game Programming is adequate. If you’re looking to learn PHP programming, however, I’d personally recommend reading one or more of several PHP books published by O’Reilly.