Learn to program your Pocket PC using the Windows® CE
Game API! Pocket PC Game Programming will help you develop
the tools and source code needed to write multiplayer games
that can be played on wireless devices and the Internet.
You will not only learn essential programming skills for
the Pocket PC, but you will also create a programming
resource that contains routines that will come in handy
when writing a variety of games. Pocket PC Game
Programming covers the history and future of the Pocket
PC platform, essential programming tools, Windows messages,
the game loop, loading bitmaps, drawing animated sprites,
playing sound effects, advanced programming techniques, and
much, much more!
What's on the CD-ROM:
- Complete source code for the sample projects in the
book
- The complete Pocket PC Game Library from the book
- Pre-compiled executables for MIPS, SH3, and ARM
processors
- Pocket PC software and games from leading
developers
- A list of Web resources and downloadable programs
- Download link to the free full version of Embedded
Visual Tools 3.0
Contents
Part I: Writing games for the
Microsoft Pocket PC Platform
Chapter 1: Introducing
Microsoft Pocket PC
Author's expectations
Reader's expectations
Requirements
Microsoft Windows Powered Pocket PC
A brief history of Windows
CE
The different flavors of Windows CE
Which Pocket PC Model should I buy?
Pocket PC Hardware
considerations
Recommended
specifications
Decisions, decisions
Software Considerations
Operating system
Applications
Pocket PC as a gaming platform
DirectX for Windows 95
DirectX for Windows CE?
Single-Player and Network Gaming
Single-Player games
Network games
Wireless multi-player gaming?
Wireless Services
Cellular Systems
Wireless Ethernet
Bluetooth
Ricochet
Wireless Software
Game Programming Library Summary
Chapter 2:The art of game design for Pocket
PC
So you want to write a game?
Going back a few years
History and Growth of the
Game Industry
Pong
Spacewar
Full Circle
What's Next?
The Theory of Computer Game Design
Game Design Comes
First!
Feasibility Study
Phases of Game Development
The Infamous Alpha
Prototype
Divide and Conquer
The Pocket PC Game Market
Action and Arcade Games
Board, Puzzle, and Card Games
First-Person Shooters
Sports Games
Turn-Based Strategy Games
Real-Time Strategy Games
Role-Playing Games
Simulations
Flight Sims
Driving Sims
Space Combat Sims
Unique Games
Summary
Chapter 3: Pocket PC Game Programming Tools
Game Development for Windows CE
Potential for Greatness
Moore's Law
Mobile Processors
Mobile 3-D Accelerators
Mobile Gaming
Tools of the Trade
Graphics Editors
Paint Shop Pro
Pocket Artist
Sound Editors
Cool Edit Pro
Microsoft Embedded Visual Tools 3.0
System Requirement
Software Development Kits
Windows CE SDK for Visual Studio 6.0
Installing the Tools
Embedded Visual
C++
EVC Basics
EVC Features
EVC
File Extensions
Embedded
Visual Basic
EVB Basics
EVB Features
EVB File Extensions
Getting Help (Finally!)
Third-Party Development Tools
NS Basic/CE
Pocket C
Summary
Chapter 4: Windows CE Programming in a
Nutshell
Windows Event-Driven Architecture
Multitasking
Multithreading
Event Handling
Windows Program Basics
Understanding WinMain
The WinMain Function
Call
The Structure of WinMain
Understanding InitIinstance
The InitInstance Function
Call
The Structure of InitInstance
Understanding MyRegisterClass
The MyRegisterClass Function
Call
The Structure of MyRegisterClass
Understanding WndProc
TheWndProc Function
Call
The Structure of WndProc
Static Library Basics
Summary
Chapter 5: Writing Your First Pocket PC
Program
Using Embedded Visual Basic
The Visual
Basic
Language
Exploring EVB
The Program Menu Bar and
Toolbar
The Project Window
The Properties Window
The Toolbox
The Editor Window
Writing Your First EVB Program
Working with Graphics in EVB
Creating the User
Interface
Writing the User Interface Code
Writing the Graphics Test Code
Preparing to Run the Graphics Test Program
Pocket Trivia
Creating the Setup Program
Using Embedded Visual
C++
The C++ Language
Encapsulation
Inheritance
Polymorphism
Exploring EVC
Program Menu Bar and
Toolbars
Workspace Window
Output Window
Edit Window
Writing Your First EVC Program
Working with Graphics in EVC
Setting Up the Graphics
Demo
Modifying the Project
Creating the GraphicsDemo Function
Summary
Part II: Building a Custom Pocket PC Game Library
Chapter 6: Using the Pocket PC Game API
The Pocket PC Game API
Similarities to DirectX
Limitations
Game
API Structures
GXDisplayProperties
GXKeyList
GXScreenRect
Game API Functions
GXGetDisplayProperties
GXGetDefaultKeys
GXOpenDisplay
GXCloseDisplay
GXBeginDraw
GXEndDraw
GXOpeninput
GXCloselnput
GXSuspend
GXResume
GXSetViewport
GXlsDisplayDRAMBuffer
How to Use the Game API
Stay Up-to-Date!
GAPI Game Loop
Blasting Pixels to the Screen
GAPI Video Modes
GAPI Video Frame Buffer
Shifting Bits for Speed
Plotting Perfect Pixels
Clearing the Screen
Warp Speed
Handling Buttons
Blackout: A Complete GAPI Game
Features and
Limitations
Writing Blackout from Scratch
Header
Common Windows Functions
Window Callback Function
Timer Callback Function
ClearScreen and DrawPixel 16
Initialization
Updating the Game
Collision Detection
Handling the Ball
Drawing the Blocks
Ending the Game
Summary
Chapter 7: The Game Library
Creating the Game Library Project
Static Library
Precompiled Headers
Encapsulating the Windows
GDI
Creating CGameLibrary
Game Events
Gamelnit
GameStart
GameActivate
GameEvent
GamePaint
GameEnd
StylusDown
StylusMove
StylusUp
Game Library Header File
Game Library Source File
Creating the Source File
Constructor and
Destructor
Initialize
EventHandler
Error
Shutdown
G_BeginDraw and G_EndDraw
GAPI Support Routines
WndProc
WinMain
MsgBox
Demonstrating the Game Library
Creating the Demo
Project
Game Library Demo Program
Double Buffering
Encapsulating the Game API
Supporting the Game API
Overhauling the Blackout Game
Summary
Chapter 8: Bitmaps
What Is a Bitmap?
Bitmap Images
Image Compression
The Need for Bitmaps
Bitmap-Based Games
Background Images
Sprite Images
Textures
Bitmap File Structure
Bitmap File Header
Bitmap Info Header
Color Lookup Table
Image Data
Loading Bitmap Images
Windows Bitmap Loading
Functions
LoadBitmap
SHLoadDIBitmap
Writing a Custom Bitmap Reader
LoadDIB
Support Functions
Converting the DIB
Drawing Bitmaps
What Is Blitting?
Windows CE Blitting Routines
The Bitmap Header
BitBlt
StretchBlt
MaskBlt
TransparentImage
Encapsulating the Bitmap Reader
Adding CBitmap to the Game
Library
The CBitmap Class
Recompiling the Library
Testing the Bitmap Class
Creating the UFO
Project
Linking to the Game Library
Summary
Chapter 9: Sprites and Animation
What is a Sprite?
Building the Sprite Engine
Encapsulating Sprites
Inheriting the Bitmap
Keeping Track of Sprites
Position
Direction
Velocity
Sprite Animation Cycle
Collision Detection
Techniques for Detecting
Collisions
Bounding Rectangle
Intersection
Using IntersectRect
Static Sprites
What Is a Static
Sprite?
Adding CSprite to the Library
Defining the Sprite Class
Loading Static Sprite Images
Displaying Static Sprites
Writing the Sprite Class
Dynamic Sprites
What Is a Dynamic
Sprite?
Adding CAnimSprite to the Library
Defining the Animated Sprite Class
Loading Sprite Animation Sequences
Loading a Tile
Loading an Animation
Sequence
Sprite Animation
Writing the Animated Sprite Class Fish Aquarium
Creating the Fish Aquarium
Project
Linking to the Game Library
Writing the Header
Writing the Source Code
Summary
Chapter 10: Sound Effects and Music
Understanding Sound Waves
The Physics of Sound
SineWaves:The Building
Blocks
How the Human Mind Perceives Sound
Sound Propagation and Waveforms
Frequency
Amplitude
Digital Sound Hardware
Digitizing Sound
Digital Sound and Music
Writing the CWaveDevice Class
Detecting Sound
Hardware
Sound Device Capabilities
Header Dependencies
CWaveDevice Definition
CWaveDevice Implementation
Loading Waves
Wave File Format
Wave File Reader
Playing Waves
Windows CE Sound Support
PlaySound
sndPlaySound
Handling Sound Playback
Real-Time Multichannel
Playback
Fully Preemptive Playback
Queued Priority-Based Preemptive Playback
Priority-Based Preemptive Playback
Writing the CWaveOut Class
CWaveOut Definition
CWaveOut Implementation
Getting Your Feet Wet
Creating the Wave Test
Project
Wave Test Header
Wave Test Source Code
Summary
Chapter 11: Button and Stylus Input
Pocket PC User Interface
Software Interface
Software Input Panel (SIP)
Keyboard
Character Recognizer
Handwriting Recognition
Hardware Interface
Stylus Input
Button Input
Working with Hardware Buttons
Detecting Button Presses
Physical Buttons
Logical Buttons
Enhancing the Game Library
ButtonPress
ButtonRelease
Modifying GameLibrary.h
Modifying GameLibrary.cpp
Testing Button Events
Displaying Button
Positions
Writing the Code
Button Test Program
Header
Button Test Program Source Code
Working with the Stylus
Receiving Messages from the
Stylus
Stylus Events
Perfect Match
Goal of the Game
Building the Game
Perfect Match Game
Header
Perfect Match Game Source Code
Recompiling the Game Library
Compiling for the Target
Processor
Source Code Directories
Summary
Chapter 12: Alien Invasion
Alien Invasion
Overview of the Game
Goals and Scoring
Player Ship
Enemy Ships
Winning the Game!
User Interface and Gameplay
Title Screen
Game Screen
Sound Effects
User Input
Enhancing the Game Library
Adding New
Functionality
Compiling the Game Library
Building the Game
Creating the Game
Project
Header File
Source Code File
Enhancing the Game
Power-Ups
Improvements
Summary
Part III Advanced Game: Programming Techniques
Chapter 13: Strategy and Tactics
The Art of Wargaming
Game Genres
Mods
Consoles
Simulating War
Computer-Controlled Players
Artificial Intelligence
Supercomputers
Computer Processing
Speed
ASCI White
Programming Intelligence
Neural Networks
Genetic Algorithms
Intelligent Computer Players
Game State
Pursuit and Evasion
Calculating
Trajectories
Detecting Incoming Projectiles
Computer-Controlled Maneuvers
Tank Battle
The Game Project
Tank Battle Header
Tank Battle Source Code
Compiling the Game
Summary
Chapter 14: Game Physics
Making Games More Realistic Particle Attraction
Building the Simulation
Program Header File Program
Source Code File
Gravity Wells
Gravitic Propulsion
Simulating Planetary Orbit
Meteoroids
Building the Game
Game Header File Game Source
Code File
Summary
Chapter 15: Intrared and Socket
Communications
Essentials of Multi-player Gaming
All About Connectivity
Infrared
Network
Internet
TCP/IP Protocol The Client/Server Model
Single and Multiple
Connections
A Server Behind Every Client
Infrared Programming
Writing the Infrared Test
Program
Infrared Test Header
File
Infrared Test Source Code File
Socket Programming
The Windows Sockets API
Socket Functions
Socket Structures
Writing the Socket Test Program
Socket Test Header File
Socket Test Source Code File
Summary
Chapter 16: Multiplayer Game Programming
Pocket Air Hockey
Rules of the Game
Scoring Points
User Interface and Game Layout
Server Options Screen
Client Options Screen
Background Image
Sprites
Sound Effects
Two-Player Support
Client/Server Architecture
Hosting a Game Server
Joining a Game Server
Development and Testing
Simulating the Client
Simulating the Server
Connecting Your Pocket PC to a Network
Setting the Device Name
Installing the Network Card
Using ActiveSync Over the Network
Socket Messaging System
Chat Messages
Virtual Keyboard
Sending Chat Messages
Receiving Chat Messages
Building the Game
Creating the Game Project
Linking to the Game
Library
Pocket Air Hockey Header File
The CField Support Class
CField Header File
CField Source File
Pocket Air Hockey Source Code
Game Events
Stylus and Button Events
Dealing with the Puck
Updating the Score and Pausing
Displaying Chat and Status Messages
Handling the User Interface
User Interface Support Functions
Sending and Receiving Socket Messages
The Socket Thread
Establishing a Socket Connection
Initializing the Winsock Library
Sending Socket Messages
Creating the Socket Server
Compiling the Game Project
Summary
Epilogue: Congratulations!
What About the Future?
The Computer Game Industry
Contacting the Author
Appendix A: Game Library Event Reference
Gamelnit
GameStart
GameEnd
GameActivate
GameEvent
GamePaint
StylusDown
StylusMove
StylusUp
Button Press
Button Release
Appendix B: Pocket PC Web Sites
PocketGamer
AtomToGo
CECRAFT
Filmspeed for Pocket PC
Flash Enabled
FunMail's Fun
Handango
A Brief History of Windows CE
Jimmy Software
Macromedia
Microsoft
NS Basic/CE Compiler
Orbworks
Pocket DOOM
Pocket Quake
Pocket Hexen
Pocket Movies
Smashing Ideas
Sony
The Gadgeteer
ZlOSoft
Appendix C: Recommended
Reading
Appendix D: What's on the
CD-Rom?
Appendix E: Installation
Instructions
Index