|
|
|
|
|
|
|
|
|
|
|
|
|
|
PROGRAMMING POWER
Rocketship: writing a PalmPilot game
By Alan Jay Weiner
My son Daniel likes to play with the PalmPilot. As he's only three, most of the games are too advanced for him, although he does like DinkyPad and the "walking game" (Kyle's Quest).
This month we'll put together a small game for him. It's simple; we can expand it next month. Actually, it's not much of a game; more of a time-waster, but it's the structure for a game. We can expand on it another time.
Daniel's a typical boy; he likes motorcycles, spaceships, knights, and anything that can be turned into a gun (which he calls a "shoot gun"). At various times he either wants to be a policeman or a "bad guy." I think we'll use spaceships for this gameÉ And no shooting.
This month's version of "Daniel's Rocketship" starts with a rocket sitting on a launch pad, as shown in Figure A. When launched, it flies upward. The hardware buttons control movement left and right. As yet, there's no goal - the rocket takes off, flies to the top of the screen and the "game" is done. This is probably a bit simple, even for Daniel.
FIGURE A
Running in the emulator, our rocket has just launched. Note the smoke/fire effect.
Rocketship is based on the original "Hello, world" application I wrote in March; most of the code will be quite familiar. The new parts include using the hardware buttons and doing things as time elapses.
3É 2É 1É BLASTOFF! I use a simple technique for animating the rocket. There are four bitmaps: the rocket (shown in Figure B), the launchpad and gantry (shown in Figure C), a blank bitmap used to clear the rocket, and a bitmap of "smoke" as the rocket lifts off.
FIGURE B
 
The rocket is a simple bitmap. Roll over picture for a larger image.
FIGURE C
 
This simple set of perpendicular lines becomes the gantry when the rocket is overlayed upon it. Roll over picture for a larger image.
Initially, I draw (well, the program draws) the launchpad and gantry. Daniel launches the rocket by tapping anywhere on the screen or by pressing the "up" button. At launch, I draw the "smoke" bitmap. Then, each time a set time period goes by, I erase the rocket and re-draw it one pixel higher.
Instead of using a blank bitmap to erase the rocket, I could use WinEraseRectangle. This would make a slightly smaller program; there'd be no blank bitmap. For now, it's convenient to just draw the blank bitmap though.
Watching the clock PalmPilot programs go idle when nothing is happening. During this idle time, power usage is drastically reduced; this is key to extended battery life.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
NO HASSLE PHOTO PRINTING, SHARING, AND STORAGE -- AS LOW AS $2.54 PER MONTH
Discover an easier way to share, print and manage your photos online! Get your own online photo album site for sharing photos, as well as easy-to-use editing tools to make sure your photos look their very best. You can even order high quality prints directly from your album -- and have them delivered right to your door!
Best of all, you can also get login-free photo sharing at your personal domain name (if you have one), so your friends and family don't have to hassle with signing up or logging in just to view your pictures. It's the perfect solution for sharing, printing and storing all your favorite images!
And it's only from The Duck! Tap here to get started. |
-- Advertisement --
SECURE YOUR SITE WITH AN IRONCLAD SSL CERTIFICATE
An IronClad SSL Certificate helps you build an impenetrable fortress around your customer's credit card information. IronClad SSL Certificates are:
- Fully validated
- Up to 256-bit encryption
- Up to 10 years validity
- Stringent authentication
- Around-the-clock customer support
Build trust. Protect your customers. Grow your online business.
Tap here now and be IronClad with SSL tonight. |
|
|
|
|
|
|
|
|
|
|