Experimenting with BlackBerry Graphics!
As I said the other day, I started my space explorer game by trying out a bunch of different ways to animate the rocketship flying through space. (I’ve bundled all the source code and resources for the complete example — you can download it here.) I started by just creating a standard MIDlet using the javax.microedition.lcdui.game classes. Here’s what it looks like in the debugger:
In the image, I’ve set the debugger to show memory usage. In this case it’s “lcduispace” — the top process on the list. Next, I decided to try out the technique I described in my earlier post: use the same lcdui game implementation, but write each frame into an image buffer and transfer it from the MIDP Graphics implementation to RIM’s proprietary implementation to display it in a RIMlet. Here it is in the debugger: Read more »
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!
BlackBerry’s two Graphics implementations: Can you use them both? In the same App?
When I first started programming for BlackBerry, one of the things that struck me as most odd was the two completely independent graphics APIs. For MIDlets, there’s javax.microedition.lcdui.Graphics, and for RIM’s own profile, there’s net.rim.device.api.ui.Graphics. The two versions are so similar to one another that — if you’re careful — you can write a game that can use either of the two graphics APIs interchangeably, just by swapping out the include statements (and using a different set of lifecycle classes). That’s what I illustrated in Chapter 3 of my book.
But I wondered: What if I want to use the javax.microedition.lcdui.game package? But I still want to take advantage of RIM’s proprietary UI component handling? Is that even possible? Note that you can’t just place an LCDUI Sprite onto a RIM Screen or use lcdui Images interchangeably with RIM Images. Yet, there’s nothing to stop you from instantiating many of the lcdui graphics-related classes in a RIMlet — either type of application has access to the whole API.
Through experimentation, I found that it’s quite possible to take a game that was written using lcdui game Layers and run it in a RIMlet. The trick is the following: Read more »
QA & Dyslexia
I’ve got some BlackBerry posts coming up, but first I’d like to say a few words about why I haven’t posted anything in six months. There are two reasons:
- I don’t like Windows OS. I’ll use it if I have to, but for my dev environment at home, I was just too tempted to clean the hard drive (once I’d finished my BlackBerry book), and replace the OS with Linux. Naturally, I told myself I’d set my BlackBerry dev environment back up on some other machine or in a virtual machine or something, and — since I love installing Windows so much — you can imagine that that task hasn’t come to the top of my “to do” list.
- I’m excited about my current job, and it’s something completely different: QA engineering for Dybuster.
Dybuster is a software suite that helps dyslexic kids learn to read. For the kids it’s a game. It works by giving the kids additional ways to learn words, using colors, tones, and 3D graphical representations:
Since I’ve been testing it, I can say that it has definitely improved my spelling in German. Of course I’m not Dyslexic.
And, fortunately, there’s an English version available too (including a free downloadable demo version).
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.
A basic QTestLib and qExec example (for engineers with experience in Q.A., not Qt!)
When doing a software QA project, you have to be ready to set up and design tests in a variety of different programming (and scripting) languages — to best integrate the automated tests with the rest of the project. I’ve worked in C/C++, but I’m far from being an expert on the subject. So I can end up wasting time on points that would be extremely simple for an engineer who works in C or C++ every day. And since I wasted my time on this, I’m posting my notes so that you won’t have to do the same.
I recently added some tests to the automated build of a C++ project that uses Qt, which has a built-in unit testing framework: QTestLib. QTestLib seems reasonably well-designed in terms of features. There were just a couple of points I felt were missing from the tutorial, so I’m posting a few remarks for the sake of Q.A. engineers who need to dive straight into the Qt unit test framework. (Apologies in advance to C/C++ developers who will undoubtedly find these points laughably trivial…)
I’m assuming here that you’ve already done at least the first chapter of the tutorial. If not, go do it now — it’s very short.
Done? OK, let’s get started. My #1 problem with the tutorial is that it explains how to create a stand-alone application that runs a single QTest class, but doesn’t explain how to create an application that will use QExec to run a series of QTest test suites. Like so many things in software engineering, it’s very simple (once you know the trick). And today I’m going to tell you the trick! Read more »
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.
)
Easy, fun game sprites made with SVG!
I downloaded and installed Inkscape in order to draw an animation to play with the Scalable Vector Graphics API. Inkscape was quite helpful for creating my game’s opening SVG animation (though it would have been more helpful if it could save the file in “SVG Tiny”…). What I didn’t expect was how helpful Inkscape is for drawing standard game sprites — drawn first in Scalable Vector Graphics format, then exported as PNG files!
I needed an rocket sprite for my “Space Explorer” game. Here’s what I came up with:

You can see that the four frames give a spinning effect. (The lower row gives the frame sequence for when the engines are turned on.) I’m more an engineer than an artist, but here’s how Inkscape and SVG made it easy for me to draw this: Read more »
The BlackBerry Red Key!
When I’m running an application on a BlackBerry device — and I hit the red key — my app disappears, and the menu screen reappears. I’d guess that my app’s screen was popped off the BlackBerry screen stack, so onClose() was called and my app cleaned itself up neatly, right?
Wrong. The application was merely sent to the background.
I assume this behavior is mentioned somewhere in the bowels of the RIM documentation (although I’ve read quite a lot of it, and I haven’t seen mention of this). Nor do the sample applications appear to deal with it. I just figured it out when my colleague Andrew Davison sent me a game that plays music in the background. It was a tad loud, so I instinctively tried to shut it off in one click using the red key. And the game went away, but the music kept right on playing…
It reminds me of a little something I read in the PodTrapper story:
My curve has 32MB of RAM and 64MB of flash. The flash can be used for paging if it’s available, but on my device only about 20MB of it is, and that fills up fast installing applications (PodTrapper alone is 350k). Realizing that the OS and other apps also have to fit in RAM, leaking a 100kb string becomes a huge problem. There are lots of forum posts by people trying to figure out why their phone keeps running out of memory and needs to be rebooted. It’s a large enough problem that there are apps for automatically restarting your phone. I can definitely see why Apple has been hesitant to open up background processing on the iPhone. It’s really easy for bad developers to make the whole platform look bad.
Personally, I think it’s kind of cool that you can run apps in the background on BlackBerry, and send them to the foreground and back. However, I think the simplest, default behavior should lean towards cleaning up the app neatly, while sitting on memory and processes when your app goes out of scope should be a special behavior that advanced developers can request. Not the other way around.
So what about that red key? What if you’re developing a game or animation that makes no sense in the background, and you just want it to clean up whenever the user dismisses it?
Andrew proposed the following solution (for use in a subclass of Screen):
Freelance BlackBerry Developer Needed
I’m looking for one engineer (who has worked with BlackBerry) for a fun little project. It’s a paid project, not just a hobbyist idea.
If you’re interested, please leave a comment, and I’ll email you. Thanks!
Leave a Comment


