Contents
Games to Go: Le Voyage Dans La Lune:(Re)Making Games for Windows CE
 
 
Printer-Friendly VersionPrinter-Friendly Version
 
Latest News
spacer View All spacer
 
November 22, 2009
 
Video Game Watchdog National Institute On Media And The Family Shutting Down [11]
 
Modern Warfare 2 Infinity Ward's 'Most Successful PC Version' Yet [12]
 
New Tech, Design Details Of Project Natal To Emerge At Gamefest In February
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
November 22, 2009
 
Trion Redwood City
Sr. Evnironment Modeler
 
Trion Redwood City
Sr. Environment Artist
 
Sucker Punch Productions
3D Environment Artist
 
Sucker Punch Productions
Network Programmer
 
Sucker Punch Productions
Character Artist
 
Sucker Punch Productions
Texture Artist
 
Monolith Productions
Sr. Software Engineer, Engine - Monolith Productions - #113767
 
Sony Online Entertainment
Brand Manager
spacer
Latest Features
spacer View All spacer
 
November 22, 2009
 
arrow Upping The Craft: Susan O'Connor On Games Writing [6]
 
arrow Small Developers: Minimizing Risks in Large Productions - Part II [7]
 
arrow iPhone Piracy: The Inside Story [48]
 
arrow And Yet It Grows: Analyzing the Size and Growth of the European Game Market [5]
 
arrow NPD: Behind the Numbers, October 2009 [13]
 
arrow Reflecting On Uncharted 2: How They Did It [5]
 
arrow Sponsored Feature: Rasterization on Larrabee -- Adaptive Rasterization Helps Boost Efficiency
 
arrow Postmortem: Wadjet Eye's The Blackwell Convergence [2]
spacer
Latest Blogs
spacer View All     Post     RSS spacer
 
November 22, 2009
 
Time Fcuk [1]
 
Accepting the Inherent Value of Games
 
Planckogenesis, Part II: Song Structure & Gravy Train [1]
spacer
About
spacer News Director:
Leigh Alexander
Features Director:
Christian Nutt
Editor At Large:
Chris Remo
Advertising:
John 'Malik' Watson
Recruitment/Education:
Gina Gross
 
Features
  Games to Go: Le Voyage Dans La Lune:(Re)Making Games for Windows CE
by Jim Williams
0 comments
Share RSS
 
 
May 28, 1999 Article Start Previous Page 3 of 4 Next
 

Single Operating-System Portability

This phrase might like an oxymoron, but when creating a game for Windows CE, you have to take into account the different platforms you may have to, or choose to, support in the future. The older Windows CE machines, running Windows CE 1.00, are limited to 2-bit displays, a custom bitmap format (.2bp) and can have as small as 480x240 displays. Now, the SDK will automatically convert .bmp files to .2bp format for you, when you target version 1.0 or 1.01 of Windows CE (as I discovered to my pleasant surprise.) But, you still must know how and where you're going to display those bitmap images. The latest and greatest devices range from 240x320, four gray-scale displays to 640x480 8-bit displays, with 800x600x16-bit supported by the H/PC Pro. Therefore, the first thing we want to do is find out what display environment we're working in. The way we find this out is with GetSystemMetrics(). Where you make this call is up to you, just so long as you do it before you draw to the display. I chose to place it in the constructor for the CWizCEView class.

Advertisement

Setting Up the Display

Add four int variables to the CWizCEView class: CScreenWidth, CScreenHeight, CViewOffsetX, CViewOffsetY. We'll use these to retrieve the width and height of the screen, and to calculate the offset required to center the view on the display. The first thing we do is get the width and height of our display.

// get the width of the
// screen and save it for later
CScreenWidth = ::GetSystemMetrics(SM_CXSCREEN); CScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);

// determine what display we're using so we can
//tell which .BMP to display
If(CScreenWidth > CScreenHeight) {
COrientation = HPC;
if(CScreenHeight > 240)

COrientation = PROPC;
}
else {
COrientation = PALMPC;
}

 

We also need to add an enum for which display orientation we're using:

enum { HPC, PALMPC, PROPC };
int COrientation;

Depending upon the orientation, we'll use either a bitmap that is 320x200, or 240x240. The display orientation would not determine what bitmap we use, because we'd be using a tilemap to draw the display. But for now we're just pasting a .bmp to the screen. Try to compile this; there should be no noticeable difference in the application, but now is a good time to test this part of the code before we go on.

Showing the Backdrop

Now it's time to add the .bmps we'll be using. We'll add them right into the project for now, rather than having them accessed as files later. That prevents some headaches and saves the overhead of writing the file access routines. Later we won't do this, because we'll want the ability to change bitmaps without recompiling the application (for developing a sequel, for example.)

How to include bitmap resources in a Visual C++ project is beyond the scope of this article, so I'll just say that you should add two bitmap resources for Hall1.bmp and Hall2.bmp, and name them Hall1 and Hall2. Hall1 is the landscape orientation of the background bitmap for HPCs, and Hall2 is the portrait orientation for PalmPCs. Create a CBitmap class object as part of the CWizCEView class called "Background". Insert the following code into the CWizCEView() constructor after the code we've just added:

 

if(COrientation == PALMPC){

 

CViewOffsetX = (CScreenWidth - WPORTRAIT)/2;
CViewOffsetY = (CScreenHeight - HPORTRAIT)/2;
CViewWidth = WPORTRAIT;
CViewHeight = HPORTRAIT;
Bitmap.LoadBitmap(TEXT("Hall2"));
}
else {
CViewOffsetX = (CScreenWidth - WLANDSCAPE)/2;
CViewOffsetY = (CScreenHeight - WLANDSCAPE)/2;
CViewWidth = WLANDSCAPE;
CViewHeight = HLANDSCAPE;
Bitmap.LoadBitmap(TEXT("Hall1"));

 

}

What we do here is straightforward, preparing for the future. Depending upon the orientation of the display (landscape for HPCs, portrait for PalmPCs), we set the view offset with this formula, which centers the bitmap in the display. We'll have to use these offsets for all of our drawing, to keep the backdrop, sprites and foreground objects all displayed in the same screen area. The Loadbitmap calls load the appropriate bitmap from which to get the backdrop imagery, again dependent upon the display orientation. For HPCs or HPC Pros, it selects Hall1.bmp, the landscape orientation. For PalmPCs, it selects the portrait orientation.

The TEXT macro is one of those Windows CE gotchas you need to watch out for. For Windows 9x, the LoadBitmap call uses a LPCSTR pointer; in MFC, they use the _T() function to convert to Unicode; in Windows CE, we have the TEXT macro. Basically all this does is convert a 1 byte/character ANSI string into a 2-byte/character Unicode string.

 
Article Start Previous Page 3 of 4 Next
 
Comments

none
 
Comment:
 


Submit Comment