Click here to Skip to main content
15,867,686 members
Articles / Mobile Apps

Bubbles for Pocket PC

Rate me:
Please Sign up or sign in to vote.
4.42/5 (9 votes)
13 Sep 2000CPOL 250.3K   635   59   35
An addictive game for PocketPCs with full source code included.

Bubbles about dialog

Introduction

Bubbles is a board game designed for use on the Pocket PC. The game starts with a board full of colored balls (called bubbles). Adjacent bubbles with the same color can be removed from the board. The more bubbles you remove in a turn, the more points you score. When you clear the entire board you get bonus points.

Bubbles was my first try to create a Windows CE program for the Pocket PC. It first used MFC, but I switched to ATL pretty early during the project. The game demonstrates how ATL can be used to create Windows CE programs with a small memory footprint.

Infrared support is one of the most appealing features of Windows CE, so I wanted to enable IrDA support as well. High scores can be transferred between CE devices (or Windows 2000) using IrSockets. It's relatively easy to use and the project contains some wrapper classes to enable IrDA sockets (nonblocking to avoid lockups).

During the development of this game I noticed that the CE environment isn't as mature as the desktop Win32 environment. STL and WTL are both missing. ATL for Pocket PC isn't as stable as its Win32 counterpart. The emulator locks up when you play several wave files after each other.

Bubbles game window

The most annoying bug is in the ATL handling of WM_INITDIALOG. Due to a very trivial error in this piece of code you are forced to override this method (otherwise SHInitDialog won't be called). If you want to call SHInitDialog yourself, then you need to override the method and pretend that you never did (otherwise ATL will call it again with it's own set of arguments). Very annoying and it took me a while, before I figured out that this was wrong.

Most Pocket PC applications allow only one single instance. If the application is started again it reactivates the first instance of the application. Despite 95% of the Pocket PC programs need this functionality there is no support in the API (or ATL) to accomplish it in an easy way. You need to register your own window class and when the application starts, you need to look for that window class. If it exists, then you need to bring the window to the foreground to activate the application again. Unfortunately, this doesn't work good when your main window wasn't the active window when you deactivated the application (i.e. a dialog was on screen). In that case the main window is activated and this causes some problems. The OK button of the dialog isn't visible. The dialog's OnActivate isn't called, so the SIP (soft input panel) isn't disabled, etc...

Despite these problems this game can serve as a good starting point for your own games. Game logic is separated from UI and highscore, options and about screens can be easily reused. I started writing a Tetris clone using this template and I hope it can be useful for you as well.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionWhy don't Build setup for MIPS CPU? Pin
28-May-01 15:37
suss28-May-01 15:37 
QuestionHow to load project? Pin
Matt Philmon17-Jan-01 15:12
Matt Philmon17-Jan-01 15:12 
AnswerRe: How to load project? Pin
Matt Philmon17-Jan-01 15:52
Matt Philmon17-Jan-01 15:52 
GeneralRe: How to load project? Pin
22-Mar-01 11:32
suss22-Mar-01 11:32 
AnswerRe: How to load project? Pin
Jae Gyu, Oh9-May-01 18:57
Jae Gyu, Oh9-May-01 18:57 
GeneralRe: How to load project? Pin
18-May-01 10:13
suss18-May-01 10:13 
GeneralMultiple Instances...history Pin
Geldar28-Sep-00 4:14
sussGeldar28-Sep-00 4:14 
GeneralFix for missing OK button Pin
KimB17-Sep-00 23:43
professionalKimB17-Sep-00 23:43 
To fix the missing OK button problem

call

::SetForegroundWindow((HWND)(((DWORD)hwnd) | 0x01));

instead of

::SetForegroundWindow(hwnd);


I saw this in the MFC code. If anyone knows the reason and details behind it, I'd like to know.
Generalerror Pin
Member 204915-Sep-00 14:12
Member 204915-Sep-00 14:12 
GeneralRe: error Pin
Member 360417-Sep-00 4:46
Member 360417-Sep-00 4:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.