Windows Mobile Game Development (eBook)
XX, 464 Seiten
Apress (Verlag)
978-1-4302-2929-2 (ISBN)
This book will provide you with a comprehensive guide to developing games for both the Windows Mobile platform and the Windows Phone using the industry standard programming languages C# and VB .NET.
You will be walked through every aspect of developing for the Windows Mobile platform-from setting up your development environment for the first time to creating advanced 3D graphics. Finally, you'll learn how you can make your applications available to others, whether distributing for free or selling online.
Using extensive code samples throughout, you'll gather all the information needed to create your own games and distribute them successfully for others to enjoy.
Aimed primarily at C# developers, almost everything in the book can be used in VB .NET too. For those areas where this is not the case, workarounds are suggested so that VB .NET developers are still able to use the techniques described.
Adam Dawes is a software developer and systems architect working at a cutting-edge online service development company. He has been a compulsive programmer since the age of 4, when he was first introduced to a monochrome Commodore PET. The love affair has continued through three subsequent decades, flourishing through the days of the 8-bit dinosaurs to today's era of multi-core processors and pocket supercomputers. A constant throughout all of this has been Adam's fondness of computer games. From the very first time Nightmare Park displayed its devious maze of pathways in green symbols back in 1980, he has been a games player across a variety of genres and styles. These days he spends his spare time playing the latest 3D titles on his PC, or enjoying some of the classics in his stand-up arcade machine or sit-in cockpit driving cabinet. Creating his own games has always been a hobby and while he has no intention of becoming part of the professional games industry, he has a lot of fun developing his own titles nonetheless. Adam lives with his wife, Ritu, and son, Kieran, in the southeast of England. His web site is at www.adamdawes.com.
This book will provide you with a comprehensive guide to developing games for both the Windows Mobile platform and the Windows Phone using the industry standard programming languages C# and VB .NET. You will be walked through every aspect of developing for the Windows Mobile platform from setting up your development environment for the first time to creating advanced 3D graphics. Finally, you ll learn how you can make your applications available to others, whether distributing for free or selling online. Using extensive code samples throughout, you ll gather all the information needed to create your own games and distribute them successfully for others to enjoy. Aimed primarily at C# developers, almost everything in the book can be used in VB .NET too. For those areas where this is not the case, workarounds are suggested so that VB .NET developers are still able to use the techniques described.
Adam Dawes is a software developer and systems architect working at a cutting-edge online service development company. He has been a compulsive programmer since the age of 4, when he was first introduced to a monochrome Commodore PET. The love affair has continued through three subsequent decades, flourishing through the days of the 8-bit dinosaurs to today's era of multi-core processors and pocket supercomputers. A constant throughout all of this has been Adam's fondness of computer games. From the very first time Nightmare Park displayed its devious maze of pathways in green symbols back in 1980, he has been a games player across a variety of genres and styles. These days he spends his spare time playing the latest 3D titles on his PC, or enjoying some of the classics in his stand-up arcade machine or sit-in cockpit driving cabinet. Creating his own games has always been a hobby and while he has no intention of becoming part of the professional games industry, he has a lot of fun developing his own titles nonetheless. Adam lives with his wife, Ritu, and son, Kieran, in the southeast of England. His web site is at www.adamdawes.com.
Title Page 1
Copyright Page 2
Dedication Page 3
Contents at a Glance 4
Table of Contents 5
About the Author 15
About the Technical Reviewer 16
Acknowledgments 17
Introduction 18
Goal of This Book 18
Who This Book Is For 18
Chapter Overview 19
PART 1 Windows Mobile Development 21
CHAPTER 1 Windows Mobile and .NET 22
Looking Closely at .NET for Windows Mobile 23
Language Choices 23
The .NET Runtime Libraries 24
IDE Features 24
Emulators 24
Form Designer 25
Breakpoints 25
Debug Output 25
Preparing for Windows Mobile Development Challenges 25
Numerous Windows Mobile Versions and Editions 25
Windows CE 26
Pocket PC 26
Windows Mobile 26
Windows Phones 27
Hardware Considerations 27
Touch Screens 27
Hardware Buttons 27
Processors 28
Screen Size 28
Graphics Hardware 28
Cooperation with Devices 28
Using Visual Studio for Windows Mobile Development 29
Installing Visual Studio 29
Creating a Windows Mobile Project 30
Visual Studio 2005 31
Visual Studio 2008 31
Project Templates 33
Designing a Form 33
Running the Application 35
Working with the Emulators 37
Device Selection 37
Sharing Files with an Emulated Device 37
Re-enabling Alt-Tab 38
Emulator State 38
Obtaining More Emulators 38
Targeting Different Platforms 38
Running on a Real Device 39
Deployment Problems 40
Removing the Security Warnings 40
Changing the Deployment Directory 41
Debugging 41
Breakpoints 42
Debug Output 42
Getting Help 43
MSDN 43
Search Engines 43
Microsoft’s Windows Mobile Developer Center 43
Newsgroups 43
Windows Mobile Game Development 44
Suitable Games 44
Graphics APIs 44
GDI 44
GAPI 45
DirectDraw 45
Direct3D 45
OpenGL ES 45
Technologies Used in This book 46
Welcome to the World of Windows Mobile Development 46
CHAPTER 2 Mastering the User Interface 47
Developing for Touch Screen and Smart Phone Devices 47
The User Interface Controls 49
Forms 49
AutoScaleMode Property 49
ControlBox Property 49
FormFactor Property 50
MinimizeBox Property 50
Text Property 50
WindowState Property 51
Resize Event 51
Creating Non-Full-Screen Forms 51
Losing and Gaining Focus 52
Labels 53
Buttons 53
Menu Bars 54
Menu Design Considerations 54
Submenus 55
Smart Phone Menus 56
Working with MainMenu Controls 56
MainMenu Events 56
Menu Item Naming 57
Context Menus 57
Timers 58
Timer Initialization 58
Concurrent Tick Events 58
Timers on Inactive Forms 59
Other Timers 59
File Dialog Controls 60
Input Panels 61
Capturing Camera Images 63
The “Busy” Cursor 64
On with the Game 65
PART 2 Creating Games 66
CHAPTER 3 GDI Graphics 67
All About GDI 67
Let’s Paint 67
Invalidating a Form 69
The Drawing Coordinate System 69
Colors 69
Pens and Brushes 71
Pens 71
Brushes 72
Drawing Lines 72
Drawing Polygons 73
Drawing Rectangles 75
Drawing Ellipses 75
Working with Pixels 76
Displaying Text 76
Using Different Fonts 77
Centering Text 78
Clearing the Background 79
Painting in Action 79
Bitmaps 80
Creating Bitmaps Using Graphics Primitives 80
Creating Bitmaps from Predrawn Graphics 81
Embedding Graphic Resources 82
Reading Graphics from Files 84
A Note About Graphic File Formats 84
Painting Bitmaps to the Screen 85
Partial Bitmap Copying 85
Scaling 87
Color Keys 87
Bitmaps in Action 88
Smooth Animation 88
Getting the Most From GDI 92
CHAPTER 4 Taming the Device with the Game Engine 93
Designing the Game Engine 93
Implementing the Engine 95
CGameEngineBase 95
Managing Game Objects 98
Game Mechanics 98
Initializing Start-Up 99
Resetting the Game 99
Rendering 99
Updating the Game State 100
Advancing the Game 100
Adding Other Functions 101
CGameObjectBase 101
Positioning Objects 102
Storing Object States 103
Object Mechanics 103
CGameObjectGDIBase 103
Setting the Object State for GDI 104
Object movement 104
CGameEngineGDIBase 104
Rendering 105
Advancing the Game 106
CGameFunctions 106
Using the Game Engine 107
Creating the Bounce Example Game 107
CBounceGame 108
CObjBall 109
Getting the Game Running 111
Optimizing Rendering 114
Adding, Updating, and Deleting Objects 118
Forcing a Repaint 118
Performance Impact 119
Other Engine Features 119
Interacting with the Device 119
Minimizing and Restoring 119
Resizing the Form 121
Handling the SIP 121
Checking Device Capabilities 122
Future Enhancements 125
Next Steps 125
CHAPTER 5 Timing to Perfection 126
Affirming the Need for Consistent Timing 126
Processor Speed 126
Graphics Performance 127
Multitasking 127
Processing and Graphical Complexity 127
Development Mode vs. Released Code 127
Overcoming Performance Inconsistencies 127
Fixed Interval Updates 128
Dynamic Update Intervals 128
The Problem with Dynamic Intervals 129
Interpolated Updates 130
Applying Interpolated Updates to a Game 131
Update Frequency 133
Distinguishing Between Updates and Frames 134
Using an External Timer 135
DateTime.Now 135
Environment.TickCount 135
The High-Performance Timer 135
Timing in the Game Engine 136
Initializing and Interrogating the Timer 136
Changes to the Interpolation-Based Functions 139
CGameEngineBase 139
CGameEngineGDIBase 141
CGameObjectBase 141
CGameObjectGDIBase 142
Changes to the Noninterpolation Functions 143
Using the Game Engine 143
Let’s Bounce Again 143
CHAPTER 6 Exploring User Input 144
Touch Screen Input 144
Touch Screen Events 144
Click 145
DoubleClick 145
MouseDown 146
MouseUp 146
MoveMove 146
Selecting, Dragging, and Swiping 147
Selecting an Object 147
Dragging Objects 153
Swiping Objects 155
Adding Context Menus 159
Using Finger-Friendly Input 161
Using Multitouch Input? 162
Using Button and Keyboard Input 162
Button and Keyboard Events 162
KeyPress 162
KeyDown 163
KeyUp 164
Reading the Keyboard State 164
Input from the SIP 165
Choosing the Keyboard Input Method 165
Reading From an Accelerometer 166
Initializing the Accelerometer 166
Reading Data from the Accelerometer 167
Detecting the Presence of a Supported Accelerometer 169
Supporting Devices With No Accelerometer 171
Considering Input Design 171
CHAPTER 7 Sounding Out with Game Audio 172
Understanding Sound File Types 172
Exploring the Available Sound APIs 173
Using the Sound APIs 175
PlaySound 175
System.Media.SoundPlayer 179
AygShell Sound Functions 182
BASS.dll 184
Wrapping BASS.NET 185
Using BASS and BASS.NET in Your Projects 191
Adding Support for Sounds to the Game Engine 191
Choosing a Sound API 192
Make Some Noise 192
CHAPTER 8 Game in Focus: GemDrops 193
Designing the Game 193
Creating the GemDrops Design Brief 193
Conceptualizing the Game Controls 196
Choosing the Sound Effects 197
Outlining the Minimum Requirements 197
Writing the Game 198
Creating the Project 198
Creating the Game Form 199
Preparing the Game 200
Creating the Gem Game Object 202
Resetting the Game 205
Pausing the Game 208
Displaying the Player Gems 208
Enhancing CObjGem 208
Enhancing the Game Class 211
Updating the Player’s Gems 214
Adding Player Control 222
Moving the Gems to the Side 222
Rotating the Gems 224
Quickly Dropping the Gems 224
Implementing Control in the User Interface 227
Removing Gems from the Board 229
Removing Gem Groups 230
Removing Rainbow Gems 234
Creating Score Objects 235
Finishing Up 238
CHAPTER 9 Common Game Components 239
Managing Game Settings 239
Using the Settings Class 240
Understanding How the CSettings Class Works 242
Accessing the Settings Object 242
Setting and Retrieving Values 242
Loading and Saving Settings 243
Replacing the MessageBox 244
Using the MessageBox Class 244
Understanding How the CMessageBox Class Works 245
Accessing the Message Box Object 245
Displaying the Message 245
Creating a High Score Table 246
Using the High Score Class 246
Setting the Dialog Presentation Properties 246
Initializing the High Score Table 247
Displaying the High Scores Dialog 248
Understanding How the CHighScores Class Works 249
Accessing the HighScores Objects 249
Understanding the Data Structure 249
Presenting High Scores 250
Storing Data 250
Creating an About Box 252
Using the About Box Class 253
Understanding How the CAboutBox Class Works 255
Accessing the About Box Objects 255
Displaying the About Box 255
Using Common Game Components 255
PART 3 OpenGL ES Graphics 257
CHAPTER 10 A New Window on the World with OpenGL ES 258
Preparing to Use OpenGL 258
Hardware Support 258
Language Support 259
Understanding the OpenGL Features 259
Performance 259
Scaling and Rotation 259
Transparency and Alpha Blending 259
Rendering in 3D 260
Abstract Coordinate System 260
Color Specification 260
Drawing Primitives 261
Textures 261
Using OpenGL in Visual Studio.NET 261
Calling OpenGL from Managed Languages 261
Understanding OpenGL’s Rendering Approach 262
Considering the Hardware Capabilities and Limitations 262
Closing OpenGL Applications 263
Creating an OpenGL Program 263
Configuring the Project 263
Creating the OpenGL Environment 265
Initializing OpenGL 267
Rendering Graphics in OpenGL 269
Adding Form Functions 273
Terminating OpenGL 274
Running the Program 275
Adding Some Sparkle 276
Using Matrix Transformations 277
Setting the Identity Matrix 277
Applying Translation Transformations 278
Applying Rotation Transformations 278
Applying Scaling Transformations 279
Applying Multiple Transformations 280
Rotating Objects 280
Scaling Objects 282
Specifying Vertex Positions 282
Pushing and Popping the Matrix 282
Practicing Matrix Transformations with Example Projects 282
The Orbits Project 282
The FractalTrees project 284
Drawing Functions 287
Drawing Points 287
Drawing Lines 287
Drawing Triangles 288
Using Texture Mapping 290
Loading Graphics 290
Rendering with Textures 291
Specifying Texture Coordinates 293
Cleaning Up 295
Using Transparency and Alpha Blending 295
Applying Transparency 295
Alpha Blending 296
Alpha Blending with Textures 297
Textures with Alpha Channels 297
Additive Texture Blending 298
Controlled Transparency of Textures 298
Knowing the Available Blending Factors 298
Understanding Orthographic Coordinate Systems 299
Taking Control of OpenGL 301
CHAPTER 11 Creating 2D Games with OpenGL 302
Adding OpenGL to the Game Engine 302
Understanding the CGameEngineOpenGLBase Class 303
Initializing OpenGL 303
Rendering Game Objects 304
Accessing the Graphics Library 304
Calling Utility Functions 304
Understanding the CGameObjectOpenGLBase Class 305
Setting the Object State for OpenGL 305
Rendering Quadrilaterals 306
Performing the Capabilities Check 307
Creating the Game Form 309
Using the OpenGL Game Engine 311
Preparing the Balloons Game 311
Setting up the Projection Matrix 312
Rendering the Balloons 314
Sorting the Balloons 316
Playing the Game 319
2D Possibilities with OpenGL 322
CHAPTER 12 The Ins and Outs of the Third Dimension 323
Understanding Perspective Projection 323
Understanding the Viewing Frustum 323
Defining the Viewing Frustum in OpenGL 327
Understanding the Depth Buffer 328
Enabling the Depth Buffer 328
Rendering Transparent Objects with the Depth Buffer 330
Rendering 3D Objects 330
Defining a 3D Object 330
Removing Hidden Surfaces 336
Using Indexed Triangles 338
Lighting Your Projects 341
Introducing the Lights and Materials 341
Exploring the Types of Illumination 341
Ambient Light 342
Diffuse Light 342
Specular Light 343
Using Material Properties 344
Ambient Material 344
Diffuse Material 344
Specular Material 344
Material Shininess 344
Emissive Material 344
Exploring Light and Material Interaction 345
Using Multiple Lights 345
Reusing Lights 346
Exploring the Types of Light Source 346
Directional Lights 346
Point Lights 347
Spotlights 347
Calculating Light Reflections in OpenGL 348
Describing a Triangle’s Face Direction 348
Calculating Normals 350
Using Surface Normals and Vertex Normals 351
Adding Light to the Game Engine 352
Enabling Lighting 352
Adding the Game Engine Light Functions 353
Creating Directional Lights 355
Creating Point Lights 355
Creating Spotlights 356
Setting the Scene’s Ambient Light 356
Setting Material Properties 357
OpenGL Lighting in Action 358
Calculating Normals Programmatically 359
Using Normals with Scaled Objects 363
Mastering the 3D World 363
CHAPTER 13 Further OpenGL Features and Techniques 364
Importing Geometry 364
Introducing SketchUp 364
Creating 3D Objects in SketchUp 365
Exporting 3D Geometry 367
Using the .0bj File Format 368
Importing Geometry into the Game Engine 370
Retrieving Geometry Data 370
Manipulating Geometry Data 371
Reading Geometry Data from .obj Files 373
Using the Geometry Loader Class 373
Moving the Camera 375
Positioning the Camera 375
Adding Camera Objects to the Game Engine 376
Lights, Camera, Action! 381
Optimizing the Camera Calculation 382
Cameras and the Projection Matrix 385
Rendering Fog 385
Adding Fog Support to the Game Engine 386
Using Fog 386
Working with Billboards 388
Rendering Billboards 388
Adding Billboard Support to the Game Engine 390
Learning More about OpenGL ES 392
CHAPTER 14 Distributing Your Game 394
Preparing a Game for Distribution 394
Settings the Assembly Properties 394
Project Versioning 396
Creating an Icon 397
Building Distribution Packages 400
Switching into Release Mode 400
Creating the Setup Project 401
Adding the Setup Project’s Files 402
Creating a Programs Menu Shortcut 404
Building the CAB File 406
Selling Games 406
Creating Evaluation Applications 406
Upgrading to Full Versions 407
Using Windows Marketplace for Mobile 409
Minimizing Piracy 410
Implementing Reverse Engineering 411
Obfuscating with Dotfuscator Community Edition 412
Using Advanced Obfuscation 414
Control Flow Obfuscation 415
String Encryption 415
Symbol Renaming Schemes 415
Reflector.NET Protection 415
Resource Protection 416
Adding Obfuscated Files to CAB Setup Projects 416
Releasing New Versions of Your Game 416
Promoting Your Game 418
Go Create! 419
Index 420
Erscheint lt. Verlag | 4.8.2010 |
---|---|
Zusatzinfo | XX, 464 p. |
Verlagsort | Berkeley |
Sprache | englisch |
Themenwelt | Informatik ► Betriebssysteme / Server ► Windows |
Informatik ► Software Entwicklung ► Mobile- / App-Entwicklung | |
Informatik ► Software Entwicklung ► Spieleprogrammierung | |
Mathematik / Informatik ► Informatik ► Theorie / Studium | |
Mathematik / Informatik ► Informatik ► Web / Internet | |
Schlagworte | Audio • music • programming • Programming language • Rendering • Time • Windows Phone |
ISBN-10 | 1-4302-2929-2 / 1430229292 |
ISBN-13 | 978-1-4302-2929-2 / 9781430229292 |
Haben Sie eine Frage zum Produkt? |
![PDF](/img/icon_pdf_big.jpg)
Größe: 3,4 MB
DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasserzeichen und ist damit für Sie personalisiert. Bei einer missbräuchlichen Weitergabe des eBooks an Dritte ist eine Rückverfolgung an die Quelle möglich.
Dateiformat: PDF (Portable Document Format)
Mit einem festen Seitenlayout eignet sich die PDF besonders für Fachbücher mit Spalten, Tabellen und Abbildungen. Eine PDF kann auf fast allen Geräten angezeigt werden, ist aber für kleine Displays (Smartphone, eReader) nur eingeschränkt geeignet.
Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.
Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.
Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.
aus dem Bereich