Search PalmPower's 487 Palm-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Finishing up Rocketship (continued)

New bitmap functions
I added three new bitmap functions:

  • GetBitmapPtr gets the bitmap resource and locks it down;
  • ReleaseBitmapPtr unlocks and releases the resource;
  • DrawBitmapPtr draws it on the screen.

Using GetBitmapPtr, I open the bitmaps when the application starts. The bitmaps remain open until Rocketship exits.

Random number generator
When the game begins, a docking bay descends and moves back and forth, finally stopping at a random position.

To position the docking bay, I call SysRandom to get a random number. SysRandom returns a number ranging from 0 to 32767 (0x7FFF). This upper number is defined as sysRandomMax in the SysUtils.h header file.

For the rest of game play, I set a different random number generator seed when the program begins. I simply use the time in ticks.

Pausing for menus
When a user pops up the menu, the game should pause while he works the menu. This is now accomplished by checking which window we're in. When we start a game, the program remembers the main screen's window handle. When it goes to do background activity, it checks that the handle of the current window is that same main screen handle. As long as it is, we know the user hasn't changed anything -- he didn't raise the menu, go to the "about" screen, or whatever. Consequently, if the window handle had changed, we'd know something had changed, so we should pause the game.

When the main form is opened (at the frmOpenEvent in MainFormHandleEvent) we call WinGetActiveWindow to get the main form's window handle. When a nilEvent comes in (which we use for timing) we again call WinGetActiveWindow to see if we're still on the main window.

Avoiding flicker in animation
I took a short cut when displaying bitmaps in Rocketship. Because I have so little movement on the screen, it was suitable to simply erase the old bitmap and display the new one. Normally that would cause flickering. Ideally, we'd draw the screen update to an off-screen window, and then copy that window into the real display. The technique is more than I can explain right now, but there's a document on Palm's web site which does explain it. You'll find that document in the developer's section at http://www.palm.com/devzone/docs/animation/animate.html.

Conclusion
This will be it for Rocketship for now. There's lots of other great Programming Power topics to get into. Next month I'll start in on the serial port.

Product availability and resources
Source code and executable for this project is at http://www.ajw.com/PalmPower/ProgrammingPower/Nov98/Rocketship.zip.

Palm's white paper on animation is at http://www.palm.com/devzone/docs/animation/animate.html.

Alan Jay Weiner writes software for PalmPilots. His email address is alan@ajw.com.


« Previous  ·  1  ·  2
Other articles you might like
Home > Phones and PDAs > Palm and Treo > Programming (24 articles)
   How PDA software is born
   Program with Simplicity
   Kinectivity 2.0 brings enterprise application developers new tools
Home > Games > Palm Games > Writing a Game (3 articles)
   Setting application preferences
   Rocketship: writing a PalmPilot game
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Other PalmPower Articles
Palm gets up to date with new Tungsten family of handhelds
Create handwritten email with riteMail
Presenter-to-Go puts PowerPoint presentations on your Palm OS handheld
Looking for the cutting edge
Gain remote access to databases and PLCs
PalmSource Open House showcases what's new in the Palm community
Analysis: handheld market share
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
DominoPower: Application development, William Shatner, and the origin of the universe
OutlookPower: More about disappearing text
-- Advertisement --

ONLINE GROUP CALENDAR - FOR UP TO 100 OF YOUR CLOSEST FRIENDS
Stay organized and in control with 24/7 access to all of your important events, projects and files --whether you're at work, at home or on the road.

You can share your calendar, projects and files so everyone in your office is up to date. Plus, search your entire group to find times when everyone is available to meet, manage company resources and much more.

Organize your entire team for as low as $9.95 per year (and yes, that's where the decimal place is supposed to be!)

Tap here to get started right away.

-- Advertisement --

Sent Items Organizer
When you need to file your sent email into their proper folders based on keywords or who it's to. It's also perfect for shared mailboxes.

It also adds a "Send And File" toolbar button while you're composing (similar to the way Lotus Notes used to work) for quick and easy filing.

Find out more!

ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login