Friday, September 3, 2010

Micro JAVA Game Development












Table of Content
Table of Content .................................................................................................................. i
Copyright.............................................................................................................................. i
Trademarks..................................................................................................................... i
Warning and Disclaimer................................................................................................. i
Credits............................................................................................................................. ii
Dedication ...................................................................................................................... iii
About the Author................................................................................................................ iii
Acknowledgments ............................................................................................................. iii
Chapter 1. Introduction (or Everything I Wanted to Know About Micro Java Gaming
But Was Afraid to Ask)....................................................................................................... 1
A New Era of Gaming.................................................................................................... 1
This Book's Mission ....................................................................................................... 3
A Bit About Game Design............................................................................................. 6
Show Me the Money: Micro Game Business Models............................................. 16
Summary ....................................................................................................................... 18
Part I: Small Devices ................................................................................................19
Chapter 2. The Mobile World.......................................................................................... 20
A New Era of Gaming.................................................................................................. 20
High-End Java Devices: Set-Top Boxes, Phones, Consoles................................ 22
Personal Digital Assistants (PDAs) ........................................................................... 24
Mobile Phones and Pagers ........................................................................................ 31
Low-End Java Devices: Smart Cards and Embedded Chips................................ 40
Summary ....................................................................................................................... 41
Chapter 3. Big Games, Small Screens ......................................................................... 42
Your Competition ......................................................................................................... 42
WAP Games ................................................................................................................. 43
i-mode Games .............................................................................................................. 54
SMS Games.................................................................................................................. 55
J2ME MIDP Games..................................................................................................... 57
J2ME Palm Games...................................................................................................... 65
iAppli Games................................................................................................................. 67
What Are You Waiting For?........................................................................................ 74
Part II: Before, Between, and Beyond J2ME........................................................75
Chapter 4. Wireless Standards: How Data Goes To And Fro................................... 76
Wireless Networks ....................................................................................................... 76
The Wireless Application Protocol (WAP)................................................................ 78
Server-Side WAP......................................................................................................... 95
Handheld Device Markup Language (HDML)........................................................ 102
WAP 2.0 and xHTML Basic...................................................................................... 105
Summary ..................................................................................................................... 106
Chapter 5. Let's Talk: Instant Wireless Messaging................................................... 107
Messaging And Gaming............................................................................................ 107
Short Message Service (SMS)................................................................................. 108
Actually Sending SMS Messages............................................................................ 112
SMS and J2ME........................................................................................................... 113
Multimedia Messaging Service (MMS) ................................................................... 115
Summary ..................................................................................................................... 117
Chapter 6. Wireless in Asia: i-mode and cHTML ...................................................... 118
Using i-mode............................................................................................................... 118
Compact HTML (cHTML).......................................................................................... 119
Development Tools.................................................................................................... 125
Testing and Emulators .............................................................................................. 125
Summary ..................................................................................................................... 128
Chapter 7. The Wireless Landscape........................................................................... 129
Bluetooth ..................................................................................................................... 129
Mobile Positioning...................................................................................................... 131
m-Commerce .............................................................................................................. 135
Voice and Telephony................................................................................................. 137
Unified Messaging (UM)............................................................................................ 138
Summary ..................................................................................................................... 138
Part III: The Java 2 Micro Edition..........................................................................140
Chapter 8. J2ME Overview........................................................................................... 141
The Trinity of Java Platforms.................................................................................... 141
It's a Small World After All ........................................................................................ 142
Profiles and Configurations ...................................................................................... 143
Connected in a Limited Way: The CLDC ............................................................... 147
The Mobile Profile ...................................................................................................... 148
Summary ..................................................................................................................... 149
Chapter 9. Creating a MIDlet........................................................................................ 150
Command-Line MIDlet Development...................................................................... 150
Development Environments ..................................................................................... 152
Lifecycle of a MIDlet .................................................................................................. 156
Displaying Stuff........................................................................................................... 157
Menus and Commands............................................................................................. 161
Creating Help and About Alert Screens.................................................................. 164
Global Properties ....................................................................................................... 168
Summary ..................................................................................................................... 169
Chapter 10. Making the Most of Limited Resources................................................. 171
The Limitations ........................................................................................................... 171
Memory Limitations.................................................................................................... 172
Displays ....................................................................................................................... 174
Breaking Through the Limitations............................................................................ 175
Summary ..................................................................................................................... 176
Chapter 11. Making the Most of It: Optimizations ..................................................... 177
A Limited World .......................................................................................................... 177
Making Code Optimal................................................................................................ 177
Code Size Reductions............................................................................................... 178
Speeding Up the Code.............................................................................................. 182
Using Less Memory................................................................................................... 185
Power Consumption .................................................................................................. 187
Summary ..................................................................................................................... 187
Chapter 12. Multithreaded Game Programming........................................................ 188
Threads........................................................................................................................ 188
Extending the Thread Object.................................................................................. 189
Implementing the Runnable Interface................................................................... 190
Thread Priorities......................................................................................................... 192
Thread States ............................................................................................................. 192
Synchronizations and Deadlocks ............................................................................ 192
wait() and notify()............................................................................................ 193
Timers .......................................................................................................................... 194
Making Threads Better.............................................................................................. 195
Summary ..................................................................................................................... 196
Part IV: Let the Games Begin! ..............................................................................198
Chapter 13. High-Level Graphical User Interfaces ................................................... 199
The Screen Class..................................................................................................... 199
Forms and Alerts........................................................................................................ 200
Lists .............................................................................................................................. 200
Text Boxes .................................................................................................................. 204
Items............................................................................................................................ 205
Tickers ......................................................................................................................... 212
Additional Libraries .................................................................................................... 212
Summary ..................................................................................................................... 213
Chapter 14. Working with Graphics: Low-Level Graphical User Interfaces .......... 214
The Canvas Class..................................................................................................... 214
Painting on the Screen.............................................................................................. 217
Drawing Images ......................................................................................................... 223
Summary ..................................................................................................................... 226
Chapter 15. Entering the Land of Sprites ................................................................... 227
Sprites......................................................................................................................... 227
Image Files.................................................................................................................. 231
Collision Detection ..................................................................................................... 233
Creating Child Sprites ............................................................................................... 235
Image Transparency.................................................................................................. 236
Summary ..................................................................................................................... 239
Chapter 16. Managing Your Sprites ............................................................................ 240
Networked Game Components................................................................................ 240
Advanced Collision Detection .................................................................................. 242
The Sprite Manager ................................................................................................... 245
Summary ..................................................................................................................... 248
Chapter 17. Sprite Movement....................................................................................... 249
Floating-Point in J2ME.............................................................................................. 249
Game Initialization ..................................................................................................... 255
Movement.................................................................................................................... 256
Piecing It All Together ............................................................................................... 258
Summary ..................................................................................................................... 261
Chapter 18. J2ME Audio Basics .................................................................................. 262
Sounds Are (Barely) Possible! ................................................................................. 262
Summary ..................................................................................................................... 263
Chapter 19. Be Persistent: MIDP Data Storage ........................................................ 265
RecordStore Overview .......................................................................................... 265
RecordStore in Practice ........................................................................................ 266
More RecordStore Joy .......................................................................................... 273
Summary ..................................................................................................................... 278
Chapter 20. Connecting Out: Wireless Networking .................................................. 279
J2ME Networking Overview ..................................................................................... 279
MIDP Networking ....................................................................................................... 281
Setting Up Your Game Server ................................................................................. 285
Data Format ................................................................................................................ 286
Making a Multiplayer Car Racing Game................................................................. 289
Summary ..................................................................................................................... 315
Part V: J2ME Extensions .......................................................................................316
Chapter 21. PersonalJava, Connected Device Configuration, and Other Micro Java
Blends .............................................................................................................................. 317
Connected Device Configuration (CDC) ................................................................ 317
PersonalJava .............................................................................................................. 318
PDA Profile.................................................................................................................. 323
Java Game Profile ..................................................................................................... 324
The J2ME Multimedia Profile ................................................................................... 324
Summary ..................................................................................................................... 325
Chapter 22. iAppli: Micro Java with a Twist................................................................ 326
The Architecture of It All............................................................................................ 326
iAppli: Like MIDP, But Not Quite.............................................................................. 330
Developing iApplis ..................................................................................................... 341
Summary ..................................................................................................................... 343
Chapter 23. Siemens Game API.................................................................................. 345
Getting Set Up ............................................................................................................ 345
The Game SDK Overview ........................................................................................ 348
Images and Sprites.................................................................................................... 348
Graphic Objects.......................................................................................................... 350
Sprites......................................................................................................................... 350
TiledBackground .................................................................................................. 353
Flashing ....................................................................................................................... 356
Good Vibrations.......................................................................................................... 357
Music, Sweet Music ................................................................................................... 357
GSM Functions........................................................................................................... 360
Input Output ................................................................................................................ 361
Summary ..................................................................................................................... 362
Part VI: Micro Racer................................................................................................364
Chapter 24. Micro Racer: Putting It All Together....................................................... 365
The Bad News ............................................................................................................ 365
The Good News ......................................................................................................... 366
Putting Together the Pieces ..................................................................................... 366
One Game Running Everywhere............................................................................. 383
Summary ..................................................................................................................... 385
Part VII: Appendixes ...............................................................................................386
Appendix A. Low-Level GUI Classes .......................................................................... 387
Game Classes ............................................................................................................ 387
javax.microedition.lcdui.AlertType..................................................... 388
javax.microedition.lcdui.Command.......................................................... 389
javax.microedition.lcdui.Display.......................................................... 389
javax.microedition.lcdui.Displayable ................................................ 389
javax.microedition.lcdui.Canvas ............................................................ 389
javax.microedition.lcdui.Screen ............................................................ 390
javax.microedition.lcdui.Alert............................................................... 390
javax.microedition.lcdui.Form................................................................. 390
javax.microedition.lcdui.List................................................................. 390
javax.microedition.lcdui.TextBox.......................................................... 391
javax.microedition.lcdui.Font................................................................. 391
javax.microedition.lcdui.Graphics ....................................................... 392
javax.microedition.lcdui.Image............................................................... 392
javax.microedition.lcdui.Item................................................................. 393
javax.microedition.lcdui.ChoiceGroup ................................................ 393
javax.microedition.lcdui.DateField..................................................... 393
javax.microedition.lcdui.Gauge............................................................... 393
javax.microedition.lcdui.ImageItem..................................................... 394
javax.microedition.lcdui.StringItem................................................... 394
javax.microedition.lcdui.TextField..................................................... 394
javax.microedition.lcdui.Ticker ............................................................ 394
Appendix B. MIDP 1.1 ................................................................................................... 395
Main Packages........................................................................................................... 395
java.io Class Hierarchy ...................................................................................... 395
java.io Interface Hierarchy ................................................................................ 396
java.lang Class Hierarchy ................................................................................. 396
java.lang Interface Hierarchy............................................................................ 397
java.util Class Hierarchy ................................................................................. 397
java.util Interface Hierarchy............................................................................ 397
javax.microedition.io Class Hierarchy..................................................... 397
javax.microedition.io Interface Hierarchy............................................... 397
javax.microedition.lcdui Class Hierarchy.............................................. 398
javax.microedition.lcdui Interface Hierarchy........................................ 398
javax.microedition.midlet Class Hierarchy ........................................... 398
javax.microedition.rms Class Hierarchy .................................................. 398
javax.microedition.rms Interface Hierarchy ............................................ 398
Appendix C. Siemens Game API................................................................................. 400
Game Classes ............................................................................................................ 400
Siemens GSM Classes ............................................................................................. 402
Input/Output Classes ................................................................................................. 402
Appendix D. The iAppli API........................................................................................... 404
Packages..................................................................................................................... 404
com.nttdocomo.io Interfaces............................................................................ 404
com.nttdocomo.io Interfaces............................................................................ 404
com.nttdocomo.lang ........................................................................................... 405
com.nttdocomo.net.............................................................................................. 405
com.nttdocomo.ui................................................................................................ 405
com.nttdocomo.ui Interfaces............................................................................ 406
com.nttdocomo.util ........................................................................................... 407
com.nttdocomo.util Interfaces ....................................................................... 407
IApplication.......................................................................................................... 408

Download
Another J2ME Books

No comments:

Post a Comment

Related Posts with Thumbnails

Put Your Ads Here!