|
On Draw
The OnDraw()
function within the CWizCEView
class is the document/view architecture's equivalent of the standard Windows
OnPaint() call. It is here
that we use the standard GDI calls to blit the background bitmap to the
screen:
CDC memDC;
memDC.CreateCompatibleDC(pDC);
//Select Bitmap into
Memory DC
memDC.SelectObject(&Background);
pDC->
BitBlt(CViewOffsetX,CViewOffsetY,
CViewWidth,ViewHeight,&memDC,0,0,
SRCCOPY);
The background is a lot
easier to blit than the sprites will be. Windows CE supports a subset
of the ROP calls that Windows 9x and Windows NT support. pDC represents
the PaintDC pointer that is passed to OnDraw.
The memDC allows us to
prepare the Background bitmap before blitting it to the screen. SRCCOPY
does a straight copy, overwriting everything underneath. Later, when we
piece together the foreground and background imagery from separate bitmaps,
we'll use other ROPcodes to create a stencil.
With the variables we've
set up, we can use a bitmap of whatever size we choose, and automatically
adjust display for PalmPCs, H/PCs, and even the newer Pro machines with
the higher resolution display. If more display types become available,
it might be preferable to change the if/else statements into a switch/case
procedure.
What you should see in
your desktop emulation if everything went right is shown in Figure
7. I have my emulation environment set to dimensions of 480x240,
a remnant of another project.
Conclusion of Episode I
In this half of the tutorial,
we examined the development environment, learned a couple of differences
between Windows CE and Windows 9x, judged the pros and cons of MFC for
use in Windows CE game development, and set up the basics for the display
functions of a Windows CE game. In the second half, we'll really get busy.
I'll go into the animation requirements for sprite images (including the
required bitmasks,) discuss the unique control system involved in a pen-based
interface, examine the "object store", and suggest a technique for storing
image data in a reusable, extensible form.
Jim has been involved
in developing software since 1980, and has developed a taste for operating
systems as esoteric as AmigaDOS and PalmOS. He's currently working on
an RPG engine for Windows CE. His only advice for someone trying to program
Windows is, "Punching the monitor hurts you more than Microsoft". He can
be reached as amok@ionet.net.
|