Games programming is what got me into computers some 15 years ago. If you're at all like me, then the magic, brightly colored animation radiating out of computer games attracts you like a moth to light. But being fascinated by computer games (and their internals) and being able to program them are two different things altogether. I had to learn the trade the hard way -- by staring at games for hours until you could see how they worked. These days you can cheat and take a short-cut: Pick up a book and just "mind meld" with the experienced programmer who disgorges all his experience, tips, and tricks.
Bearing in mind that some Java books (see the Laura Lemay book listed below in the Resources section) these days want to lead you up different paths altogether, you could do worse things than trust an ex-(commercial)games programmer to review the currently available Java game programming books.
Four titles landed on my doorstep for this review:
Black Art of Java Game Programming, by Joel Fan, Eric Ries, and Calin Tenitchi (Waite Group Press)
Cutting-Edge Java Game Programming, by Neil Bartlett, Steve Simkin, and Chris Stranc (Coriolis Group Books)
Developing Java Entertainment Applets, by John Withers (Wiley)
- Teach Yourself Internet Game Programming with Java, by Michael Morrison (Sams.net)
Before I review the books in detail, let's start with a table that gives you a bird's-eye view of their main characteristics:
Table 1: Java Game Programming Books Overview.
|Title (Publisher)||Price(US$)||Pages||Chapters (Appendices)||CD- ROM?||Authors||Object- Orientation||Networked Multi-User Focus||Game Framework Focus|
|Black Art of Java Game Programming (Waite)||49.99||933||20 (5)||Yes||3++|
|Cutting-Edge Java Game Programming (Coriolis)||39.99||523||21 (2)||Yes||3|
|Developing Java Entertainment Applets (Wiley)||29.95||392||10 (0)||No||1||Poor||Poor||Average|
|Teach Yourself Internet Game Programming with Java (Sams.net)||39.99||416||21 (3)||Yes||1||Average||Good||None|
To describe the table headings, the Object-Orientation column highlights to what extent the author(s) of the respective book used Java the way it is meant to be used: in an object-oriented way. Good Java books, whatever their focus, enforce good object-oriented practices. Inferior books use Java as if it was C or Pascal -- that is, in a procedural way. Games are very good candidate applications that benefit from being designed and implemented using object-orientation, so a good Java games book better be strong on OOA/OOD/OOP (OO Analysis, Design, Programming).
The Networked Multi-User Focus column highlights how much the book focuses on Java's strongest game programming potential: networked, multi-user games.
The Game Framework Focus column highlights to what extent the book relies on a game framework to explain and develop games programming. Game frameworks are state-of-the-art game APIs that eliminate many of the standard tasks that all games have to perform (sprite management, screen repainting, score keeping, and so on).
Now, a look at the books in detail.
Black Art of Java Game Programming
Black Art of Java Game Programming is one of those Bible-type books -- all 933 pages of it. The book is logically structured into three parts:
- "Fundamentals of Java Game Development"
- "Advanced Game and Graphics Techniques"
- "Game Gallery"
Part 1, which is written entirely by the book's main author (Joel Fan), expertly weaves the three subject threads of Java, object-orientation, and game programming fundamentals into one clear, refreshing, and coherent whole.
Part 2 focuses on networking and 3D techniques. One chapter develops a server-side high score management system while another develops an entire chat-room system. Both these systems entail client-side and server-side programs (applets and servers, in other words). The only two chapters dealing with 3D read like a book within a book: In over 110 pages Calin Tenitchi crunches through all the classic 3D basics and, in his second chapter, analyzes the use of a large but very well-designed 3D game framework called App3DCore. With the official Java 3D API on the horizon, this part of the book will soon be partially obsolete, although much of the framework deals with higher-level aspects than Java 3D so this is not a problem for the book. At any rate, having the insides of such a 3D framework explained is very enlightening.
Part 3, the Game Gallery, contains eight chapters, each of which develops an entire game. The games vary in sophistication, which gave me the impression that this part of the book was rather hastily put together. The individual design and implementation of the games is (overall) of the same high quality as the rest of the book, though. There's a vector-based Asteroids clone, Othello, a Web-based Mahjong, a horizontally-scrolling, word-shooting edutainment game, two different magic-square games, and an incarnation of the classic Worm (or Snake, if you prefer) game.
Although the book is not without its share of glitches, errors, and so on (for example, one page contains a code listing that is mangled beyond belief), I liked it a lot. The book has many strengths and few weaknesses. It is strong on good program analysis and design. (Ah! you thought you could skip those stages just because they're games? Wrong.) The book uses various types of diagrams very effectively (object diagrams, class diagrams, flowcharts, state machine diagrams, screen prototype diagrams, and so on), and most of the code listings are very readable. (This aspect, like the writing style, does fluctuate from author to author. This is the inevitable flip-side of books written by several authors.)
Cutting-Edge Java Game Programming
I'm usually very skeptical of titles starting with "Advanced," "Cutting-Edge," and the like, simply because, usually they aren't! In the case of Cutting-Edge Java Game Programming, Coriolis's marketing department didn't hype anything up: The book definitely is not for beginners or intermediate-level Java programmers. In fact, all but the first and last chapters of the book are devoted to an in-depth, no-nonsense analysis of the design and implementation of two game frameworks. The first framework caters to single-user (stand-alone) games while the second is geared toward Internet-based, multi-user games.
Chapter 2 packs the complete implementation of an entire Asteroids clone that's playable, flicker-free, and uses smooth animation and sound. And that in just 250 odd lines of code -- or just 18 book pages! This chapter, therefore, ought to convince anyone that using game frameworks, and frameworks in general, is one of the best ways to achieve high levels of programming productivity by accentuating design reuse, rather than code reuse (but in the process also reusing mountains of code).
If Chapter 2 is a clear, promising sign of the high quality of this book, then Chapter 3 reinforces that impression by introducing us to the core theme of the book: the in-depth exploration of a (very) well-designed game framework. In passing, the author explains what CRC (Class/Responsibilities/Collaborators) cards are, the essence of Booch class diagrams, and object message interaction diagrams. By the way, this is not as page filling because the rest of the book uses these powerful software engineering tools to enhance the text!
The single-user game framework, called GameWorks, is based on the tried-and-tested game programming metaphor of a stage populated by actors. Using this intuitive abstraction, you can implement any type of game -- from classic board games to fast, action-packed arcade games. I was slightly disappointed that the authors picked card games as an example game style (I prefer something that gets the adrenaline flowing), although they nevertheless manage to weave in all the standard issues and techniques, and expertly so (among others: image processing, input management, sprites, optimized screen refresh, audio, randomness, artificial intelligence).
Although the book isn't structured around parts, it should have been. There is a clear switch of focus from chapter 15 onwards. Chapter 15, "Network Game Programming," represents a definite shift to a higher gear, with a new author doing the writing. After introducing the main issues surrounding network-based games (connection topologies, latency, game state synchronization), the book develops a clone of Risk, the classic strategy board game (called Domination in the book). Domination is only an excuse to develop a new game framework addressing the generic class of network-enabled multi-user games. These last five chapters are tough going, and I strongly suspect readers without some data communication background will not feel comfortable with the more technical arguments. But there's no way you can skip these chapters: They contain a very thorough treatment of the critical issues of game state de-synchronization and latency problems, as well as a number of increasingly sophisticated solutions.
The book winds down with a chapter on code optimization and an interesting chapter on the design of FRED, a "Doom" clone written in Java! FRED uses ray casting (yes, in Java) to achieve that classic "Doom" feel, and this core technique is explained in detail.
To summarize, Cutting-Edge Java Game Programming is excellent. The writing is lucid and to-the-point. The software that the authors develop is of very high quality. The listings are clear and readable, and I don't know about you, but after reading other people's programs for 15 years, I don't regard source-code readability as a luxury).
Developing Java Entertainment Applets
Developing Java Entertainment Applets is a very disappointing book. If a publisher gave you 400 pages in which to cram everything you know about programming games in Java (okay, okay, "Java En-ter-tain-ment App-lets"), then you do not start with a chapter that reiterates, ad nauseam, the history of Java. Or continue with "Java Fundamentals" (Chapter 4), a totally superfluous rehashing of language basics (variables, Unicode, expressions, comments, control flow, objects, classes, packages -- you name it!). The author still doesn't suspect that he might be focusing on the wrong subject entirely, so in Chapter 5, "More Advanced Techniques," he drones on with arrays, vectors, strings, exceptions, multithreading, applets. Getting ever so slightly hotter is Chapter 6, "Graphics, Sound and Events." But you'll be hard-pressed to find any references to game programming here, either. Instead, precious page real estate is devoted to bringing you no less than 13 half-page screenshots of the trivial results of
drawArc() and the like!
Half-way through the book (Chapter 7, page 219) we have the first appearance of some Java game code, in this case, an attempt at the Solitaire card game (decidedly, card games must be in season). The design of the game, the implementation of the game, and the readability of the listings are all so inferior compared to the same aspects of the other books in this review that it's clear Developing Java Entertainment Applets has problems.
Some remarkable statements made by the author, and a general sloppiness or misuse of terms that have crystal-clear meaning, only helps to sink this book before it has a chance to sail. AWT's layout management mechanism is criticized as follows: "The way layout is handled is pretty botched up. Not that it doesn't make sense and isn't for a good reason, but it is still botched up." Java's networking API also is not to the author's liking: "The way that Java hooks up to other locations on the Net is broken, and while it isn't totally unusable, it sure isn't very functional in its current state." Strange, I would have sworn that others and myself manage to create pretty exciting things with that same API (Web crawler, DAMPP -- see Resources below for references to my previous JavaWorld articles on these topics). That last quote comes out of Chapter 8, "Multiplayer Gaming," where we are nevertheless shown "a stupid little example" (to quote the book) in the form of a chat application. (Other examples of language that I find hard to swallow in this book are "to cement it in your head" (p. 283), "and spitting things over a socket" (p. 284), to quote just two.)
Isn't there anything good to say about this book? Actually, there is: Chapter 2, "The Principles of Game Design," is an interesting analysis of what makes a good game good. Here the author shines by identifying several aspects that all good games have, like a well-designed game interface, veracity (level of realism), customizability, AI, and so on. The next chapter, "Game Design in Action," analyzes some real games and highlights their use of good game design elements. Then there is one large chapter (Chapter 9) devoted to a study and use of the Gamelet Toolkit (a public domain game framework, written by Mark Tacchi, that received a JavaCup International prize). These three chapters are the only parts of the book that are worth the paper they're printed on, I'm afraid.
Teach Yourself Internet Game Programming with Java
Comparative reviews are tough because rarely are two (or more) books in exactly the same category. Teach Yourself Internet Game Programming with Java, according to its back cover, addresses users in the "new" to "casual" categories. Beginners, in other words.
With his intended audience in mind, the author takes his time explaining some very, very fundamental things -- like colors, coordinate systems, and sound waves. In fact, I found the book takes much too long to get down to business and give actual code examples. The first four chapters (or "days" in Teach Yourself marketing speak), "Games on the Web," "Java Game Programming," "Object-Oriented Programming with Java," and "The Basics of Graphics," all manage to avoid code examples. Only with Chapter 5, "Java Graphics Techniques," does code finally make a timid entré.
Because the book is targeted at an audience of beginners and would-be games programmers, you'd expect the author to jump at the opportunity to develop a game framework for his book, as part of preparing the book, and simply show the reader how to use it. Such an approach would be very attractive because it would allow one to concentrate on the high-level game design aspects and ignore nitty-gritty things like sprite management, background management, and so on. Morrison took the opposite approach, starting from scratch on all fronts, with sprites, input handling, audio, and so on. This means that the few games the book develops are very basic. The first "game" isn't even a game at all: "Sim Tarantula" animates some spiders without interacting with any player (this comes right after the chapter on "Sprite Animation," so it's really just a fancy test for the sprite code).
By the time we reach Chapter 10, the first real game is presented, called Traveling Gecko: Blistering Desert Fun. This gecko game is a reincarnation of a very old (but very playable) arcade classic: Frogger. (For those who missed that Golden Age of non-violent, thoroughly addictive video games, with Frogger the player guides a frog across a highway and then across a fast-flowing river filled with logs and crocodiles.) Traveling Gecko didn't want to work properly in my Netscape Navigator 3.0, but giving it a shot with appletviewer finally let me enjoy the game in all its (silent) glory. Only after two more chapters on audio do you get the first game to feature some sound effects. The presented game has the player catching scorpions in the night and uses a set of sound samples very effectively, although the gameplay itself is ultra-simplistic.
Part 3 of the book is the "piece de resistance": After introducing the concept of game AI (artificial intelligence), Chapter 16 develops a clone of the game Connect Four with a solid computer opponent. The game is just a prelude to the book's climax: a Web-based (2-player) Connect Four that lets two geographically separated players play together via the intermediary of a Web server-hosted Connect4Server daemon.
The author chose to present large classes in a style that I don't particularly like: Instead of including the entire source code for a class (the style I use), the author gives you bits at a time. Member variables, constructors, and methods are interleaved with the book's text. Only he often omits the import and class declaration clauses, which made me feel thoroughly "lost"; the class clause is the first thing I want to read when exploring new classes, as it acts as a kind of mental anchor. Of course, because beginners haven't yet formed habits or expectations relating to reading Java programs, the author's approach might actually be okay with them.
In summary, Teach Yourself Internet Game Programming with Java contains enough introductory material to have its targeted audience reading, learning, and experimenting for a while. The focus, however, is mainly the absolute basics of game programming, and not Internet-based game programming, which inevitably requires non-trivial network programming.
The bottom line
The four books in this review fall in two sub-categories: experienced and beginner. Black Art of Java Game Programming and Cutting-Edge Java Game Programming will appeal to mature, experienced programmers. Both books are very good and neither treats you as if you're still in kindergarten. If you want a book that focuses very hard on game framework design, then the Coriolis book is it. If you prefer a bit more diversity in topics, approaches, and number of games developed, then Waite's book should be a perfect match. If you're a beginner though, go for the Sams.net book. If you're interested in high-level (language-independent) game design issues, then Wiley's book contains some interesting insights, but stay away from it if you want to treat yourself to a great Java games programming book this summer.
Learn more about this topic
- Coriolis Group Books' Website http://www.coriolis.com/
- SAMS.Net Publishing's Website http://www.mcp.com/samsnet
- Waite Group Press' Website http://www.mcp.com/waite
- Wiley Computer Publishing's Website http://www.wiley.com
- Game Developer magazine's Web site is for the serious game programmer. Since most modern games are heavily into 3D, that's what this magazine covers a lot of. http://www.gdmag.com/
- Next Generation Online magazine's Web site is more for the playing game programmer. The latest games are reviewed here. http://www.next-generation.com/
- I have written articles on the topics of a Web crawler and DAMPP for JavaWorld. See my DAMPP article, "Create your own supercomputer with Java"/javaworld/jw-01-1997/jw-01-dampp.ibd.html
- And see my Web crawler article, "Automating Web exploration"/javaworld/jw-11-1996/jw-11-webcrawler.html