Archive for the ‘book’ Category

BlackBerry on JavaRanch!

At JavaRanch (a friendly place for Java greenhorns), they’ve just added a new BlackBerry forum!  And as an opening event, they’re doing a promotion where you can win a copy of my book Learn BlackBerry Games Development.  As part of the promo, I’m answering questions there this week.  See you there! 😀

Advertisements

Learn BlackBerry Games Development!!!

So, my new book — written with co-author Andrew Davison — is done and ready to go!

Have a look at the book’s website to get an idea of what you’ll see:

  • Chapter 1. Gaming on BlackBerry!
  • Chapter 2. BlackBerry Application Basics
    Why are there two types of BlackBerry Java applications? What are all those crazy files the compiler generated? And – most importantly – how do I get an application complied and running on my BlackBerry smartphone? Chapter 2 will answer all of these questions, plus help you set up a professional build with Ant.
  • Chapter 3. Game Graphics and Events with MIDP and RIM Classes
    Using the classic Maze game as an example, you’ll see exactly how the two types of BlackBerry Java applications differ. You get an in-depth look at how the lifecycle, events, and graphics work in both cases so you’ll be ready to develop whichever kind is best suited to your game’s needs.
  • Chapter 4. Adding a Professional Look and Feel
    Gorgeous graphics are critical for the game experience. To get your game’s visual theme pixel-perfect on every model, BlackBerry gives you the tools, and Chapter 4 explains how to use them.
  • Chapter 5. Security and Selling Your Game
    As much as you love games for their own sake, at the end of the day it’s nice to get paid. In Chapter 5 you’ll see how to sell your game on BlackBerry App World (or on your own site) – plus how to apply the cryptography APIs to implement licensing and Digital Rights Management.
  • Chapter 6. Swingin’ Light Saber
    With action, music, sound-effects, colliding game sprites, and even touch-screen input, Andrew shows you how to put it all together and develop a real game. Plus BlackBerry’s accelerometer lets you wield your saber like a true RIM-i Knight!
  • Chapter 7. Play a Live Opponent with SMS
    That classic, tiny packet of data sent by the Short Message Service is still a favorite with users and operators alike. And it’s all you need to play a trans-atlantic game of Checkers with a friend – chosen from your BlackBerry contact list!
  • Chapter 8. Using Scalable Vector Graphics
    2-D graphics are easy to master and allow you to create surprisingly impressive effects. Check out Chapter 8’s spinning spaceship video and learn the tricks to create it.
  • Chapter 9. Creating Role-Playing Games on the Internet
    Since Internet everywhere is BlackBerry’s strong point, it was practically born for Massively Multiplayer Online Role-Playing Games (MMORPGs)! Chapter 9 uses Twitter to create a virtual asteroid belt that you can explore and find real people in their own virtual ships.
  • Chapter 10. Remotely Drive a (toy) Sports Car
    What’s more fun than driving a remote controlled car? Driving one from your BlackBerry! Andrew illustrates Bluetooth programming in style.
  • Chapter 11. Fox and Hounds
    Here’s something your stationary game console can’t do: a real live game of hot pursuit – based on GPS!
  • Chapter 12. Introducing 3D with JSR 239
    Have a look at what the latest-and-greatest version 5 BlackBerry smartphones can do! Andrew explains 3-D graphics with OpenGL.

Also note: I have some “outtakes” — sample games and code that didn’t quite make it to the book but are nonetheless kind of interesting.  I’ll be posting them here over the next few months.

Beginning BlackBerry Development by Anthony Rizk

The first book in Apress’s Blackberry series appeared this past November: Beginning BlackBerry Development by Anthony Rizk. Naturally I picked up a copy because I was curious to see how his approach (and his book) compared to my upcoming book (Learn BlackBerry Games Development, written in cooperation with Andrew Davison). Fortunately, the two books cover quite different subject matter. I’d even say they’re complimentary. It turns out that there’s quite a lot to say about the BlackBerry platform because the application lifecycle/behavior/philosophy is very different from MIDP (even though you can run MIDlets on it), plus BlackBerry has a dedicated server-side network that you can program for. John M. Wargo — who reviewed Rizk’s book on Planet Lotus — says that his book on BlackBerry Development Fundamentals is also complementary with Rizk’s. (It kind of makes me wonder if there’s overlap between my book and John Wargo’s — but I doubt there’s much.)

Rizk’s book — being an intro book — doesn’t assume a high level of Java/programming knowledge. In Chapter 1, he warns the reader that “This book is not an introduction to object-oriented programming, or even to the Java language.” However, if you’ve taken one course in Java programming or have worked through an intro book on the subject, “Beginning BlackBerry Development” would be a fine next step. It covers all of the fundamentals of how to build and deploy a BlackBerry Java application, how the application lifecycle works, how to build a user-interface (and respond to user input), the differences among the four or more different types of data persistence on BlackBerry (and how to use them), the different types of BlackBerry network communications available, and how to program for the GPS.

They timed the book to come out in time for the holidays (as well as for a BlackBerry dev conference), and it’s true that the book would make a good gift for a technophile in your life who’s thinking of going into software engineering or for a software engineer in your life who has a BlackBerry and is thinking of maybe trying to sell an application on BlackBerry App World. (And if they like it — and want to take it to the next level with the techniques for making games on the BlackBerry — well, you can guess which book I’d recommend they try next. 😉 )

A range of ideas and perspectives: iPhone Games Projects

iphone_games_projectsEven though I’m still playing with MIDP for the moment, it’s fun (and instructive!) to look over the shoulder of some of the people developing games for other device platforms.  I’ve done a little bit of work on the Android platform, and naturally I’d like to know what’s up with the iPhone as well.

So I picked up a copy of iPhone Games Projects by PJ Cabrera (and others).  This book is unusual for a computer book in that they gathered up ten highly successful iPhone game developers to give their best secrets and advice, so it gives higher-level project strategy ideas instead of spelling out all of the technical nitty-gritty.

Overall, the book answers the following questions:

  • What makes an iPhone game great?
  • How do you plan and execute a successful professional iPhone project?
  • How do you optimize for the iPhone?

The authors all present different perspectives on the subject, which naturally invites the reader to contrast them and think about their ideas! Continue reading

Game page update

I’ve updated my sample game page to include links directly to the jar files (as some people have requested).

Sorry I haven’t been keeping this blog updated lately — since I’m not currently working on a book, I guess I’m not doing as many independent projects as I used to. However, I do have a new one coming up that I’m planning to post to this blog over the next couple of weeks:

As I’ve said before, the Java ME lcdui classes don’t allow enough customization of the look-and-feel to be appropriate for use in a professional application. So everyone ends up implementing their own UI classes, starting from a blank canvas. Since the basics are always the same, I was thinking of writing a simple library of basic UI navigation classes (starting from the classes I wrote for Chapter 10 of my book) and posting it. Anyone can write such classes, but perhaps it will save someone some time…

My new book just came in the mail…

I just received my box of copies of Creating Mobile Games: Using Java™ ME Platform to Put the Fun into Your Mobile Device and Cell Phone, and it looks great!!!  If I do say so myself…

Radio silence….

I’m sorry I haven’t posted anything new in a while. You might think this means I haven’t undertaken any new programming adventures lately, but you would be wrong. Oh, so very wrong. 😉

What’s up is that I’ve been working on a professional product, so of course I don’t have the same liberty to blog about what I’m doing. And it has kept me so busy that I haven’t had time for any projects on the side or even to write any general articles on technologies we’re using.

However the new product is going to production very soon, and at that point I should be able to post again. We’re working with some exciting new technologies that I’m looing forward to telling you about! 😀

Practical Java™ME Game Projects with MIDP 1/2/3

java_game_book.gifMy new book Practical Java™ME Game Projects with MIDP 1/2/3 has just been announced on the publisher’s website! It’s coming out in September.

Highlights include a lot of the same topics covered in this blog — most blog entries are at least related to projects I did for this book. The examples in the book are complete games and covered in more depth than here, plus lots of additional topics are explained and illustrated!

A Little Maze Algorithm

Way back on my Amazon reviews post, I promised I’d post an explanation of the algorithm I used to generate the random mazes for the maze game in my book.

maze.png

Unfortunately, I haven’t had time to get around to it until just now, but better late than never!!!

So, here’s how it works:

Think of the pathways through the maze as being a graph (in the Mathematical sense) where a point where two pathways join or a point where you might turn is a vertex, and then the pathways connecting the vertices are edges. It’s clear that for a maze, you want your graph to be one connected tree, in other words a graph with no cycles. As long as the entry point and the exit point are part of one connected tree, there will be exactly one path from the beginning to the end.

To apply this idea and create the maze, the first step is to use the screen and graphics dimensions to determine the size of your grid of vertices (how many squares across and how many down). In this implementation, I start by dividing the entire playing field into equal-sized squares which form part of the maze pathways if colored white, and part of the maze wall if colored black. There’s a lattice of squares that I know should be black and a lattice that I know should be white, and the trick is to figure out which colors to give to the wild-card squares.

maze_algorithm.png

Here I’ve colored gray all of the squares whose color should be decided by the algorithm (note that this screen never appears in the final game). In graph terms, the white squares are the vertices, and the gray squares are the squares that might potentially be edges by being added to the maze pathway and turned white. You can see from this that the number of rows and number of columns both need to be odd numbers.

The algorithm works by picking one of the white squares at random from the middle of the grid and growing the tree from there by picking undecided (gray) squares and turning them white. Throughout the algorithm, you maintain a list of all of the white squares (vertices) that are not yet connected to the maze, but are only one gray square away from being linked in. At each round of the algorithm, you use the randomizer to pick one square from the list and attach it to the maze (by turning a gray square white, hence adding an edge to the graph). Then just keep going until there are no white squares left that aren’t connected to the maze pathway graph, and color the remaining gray squares black.

By only adding edges to connect vertices that weren’t already connected to the graph, you can see that you’ll never get a cycle. And by growing the graph from one central point, you can be sure that all of the vertices will be connected to the same component. So in the end, for every two white squares in the maze there’s exactly one path that leads from one to the other, notably there’s a unique path from the entry square to the exit square.

For fun, I wrote a MIDlet that illustrates the maze algorithm in action. You can donwload it from my game page: it’s the one with the enticing title “Illustration of maze algorithm.”

Remember that all of the source code from the examples in my book (including the complete maze example) is available for download on the publisher’s site Apress.com. The exact page for my book is here. (The source code download is in the left sidebar under “book extras”.)

Amazon reviews

Since this blog is a companion blog for my book J2ME Games With MIDP2, today I’d like to talk about some of the book’s Amazon reviews. I won’t reprint the reviews in full here (you can see them on my book’s Amazon page), but rather just address some of the comments. I think this chunk sums up the main criticism:

It is basically a review of the code of a few simple games (like a cowboy jumping tumbleweeds, or a simple 2d maze) with very little space devoted to theory and explanations.. both of the APIs and of the internal logic and algorithms. Not that this book isn’t useful.. it is but you have to wade through a lot of code, and I think the author could have done a much better job if for example she had taken the time to EXPLAIN the maze generation algorithms instead of just saying “look at the code”.

What can I say? The text-to-code-sample ratio might not have been optimal. 😉

Actually, I wrote a lot of the theory and explanations into extensive JavaDoc comments in the sample code, but that’s obviously not the most user-friendly format, especially since this is a book. As another critical reviewer said: “If you are the type of person that learns by reading code then you will already have learned the APIs by looking at the sample code. The reason we buy technical books is to teach us how to use the APIs through a combination of well annotated example code, well organized reference material for the APIs, and illustrations that demonstrate best practice code flow.”

This is a valid point, and all I can really say is that I’m working on improving this in my technical writing. I think my bluetooth article the other day shows improvement on the points the reviewer mentions. I started with an overview of what the code needs to do, then talked a little about what options are available and explained why I chose the strategy I did. Plus I searched for additional references on the web, and provided links and a brief explanation of what points I’d learned in them and how I applied them in my project. In that article I didn’t even post the code sample (although I will at some point), essentially because I wasn’t sure the bluetooth part of the code was clear and concise enough to be useful without the complete sample program.

It’s kind of disappointing to see the maze algorithm singled out as not being explained clearly enough. Part of the point to that example was to show that you can make something fun from something simple. What happened was that since the algorithm to generate the maze wasn’t something that applies to games in general, I just wrote the explanation of how it works into the JavaDoc of the code samples. But clearly it wouldn’t have hurt to have included an overview/explanation of it in the text part of the chapter as well. I’ll take it as a challenge to write a concise explanation of the algorithm and post it here to this blog. (I want to move on to some graphics first, but maybe I’ll write up an explanation of it over the holidays since it’s something I don’t have to be sitting at the computer to do.)

I’ll close with a potitive comment from a review titled “Brings the fun back to Java”:

The author of this book has a nice, easy to read style of writing. Her enthusiasm for the topic comes through and makes you want to try the many sample games.

This is what I’m shooting for, of course. I’d like to show that it’s not only fun to play games but also to write them as you use your ingenuity to tackle the special challenges you face when programmming for a small device. 😀