Email:   


Home
In This Issue
Email a Friend
EasyPrint
Click here for the RSS feed's XML code. This is not a browser URL.


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. Click picture for a larger image.

FIGURE C

This simple set of perpendicular lines becomes the gantry when the rocket is overlayed upon it. Click 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.





[ Next ]

-- Advertisement --

BLOGGING AND PODCASTING WITH ONE EASY-TO-USE TOOL
Now you can publish your thoughts, opinions, and comments in your own blog or podcast.<p />

  • Supports multiple authors and multiple blogs or podcasts.
  • Generate and publish RSS feeds for iTunes and other directories.
  • Post photos, images or animations.
  • Get feedback and have conversations with visitors to your site. <p />

Personalize your blog or podcast with your own unique domain name -- or integrate it with your existing site by setting it up as a subdomain.

Tap here and get blogging or podcasting within minutes.

-- Advertisement --

NEW! SAFEGUARD SEND OUTLOOK ADD-IN
Prevent mistakes when sending. This add-in prompts you when certain keywords are used, when email is sent outside your company, and more. It gives senders a chance to think before hitting Send -- perfect for confidentiality reasons. Sperry Software now has 36 professional add-ins...there's one for you!

Click here to find the add-in that's right for you.
Copyright © 1998-2008, ZATZ Publishing. All rights reserved worldwide.