You are previewing Micro Java™ Game Development.
O'Reilly logo
Micro Java™ Game Development

Book Description

Micro Java Games Development explains game development for devices that support J2ME MIDP. The six parts cover a full range of topics, from a tour of all available micro-devices (Palms, cell phones and pagers), a discussion of software standards apart from J2ME (cell phones, messaging, I-mode and wireless enhancements such as Bluetooth), and available J2ME extensions (Siemans, Ericcson, Nokia), development tools and restrictions, to the creation of a meaty J2ME game!

Table of Contents

  1. Copyright
    1. Dedication
  2. About the Author
  3. Acknowledgments
  4. 1. Introduction (or Everything I Wanted to Know About Micro Java Gaming But Was Afraid to Ask)
    1. A New Era of Gaming
      1. A Brief History of Games
      2. Multiplayer Mania
      3. Micro Devices, Micro Lifestyles
      4. Enter Micro Java
    2. This Book's Mission
      1. The Game Plan
        1. Part I: Small Devices
        2. Part II: Before, Between, and Beyond J2ME
        3. Part III: The Java 2 Micro Edition
        4. Part IV: Let the Games Begin!
        5. Part V: J2ME Extensions
        6. Part VI: Micro Racer
    3. A Bit About Game Design
      1. The Game Design Process
      2. Preproduction
        1. Answering Questions
        2. Picking a Game Genre
          1. Copying, Stealing, and Cloning
          2. What Types of Games Are Possible?
        3. Know Thy Limits
          1. Designing Within Restrictions
          2. Designing Around Restrictions
        4. The Game's Mission
        5. Inputs and Outputs
        6. Gameplay
        7. Other Resources
      3. Prototyping
      4. Programming
      5. Playtesting
    4. Show Me the Money: Micro Game Business Models
      1. The Business Outlook
      2. Advertising and Sponsorships
      3. Content Deals
      4. Pay-For-Play or Subscription
    5. Summary
  5. I. Small Devices
    1. 2. The Mobile World
      1. A New Era of Gaming
        1. Micro Devices
        2. The Micro Revolution Begins
          1. Wide Support
          2. Asia
          3. Europe
          4. North America
      2. High-End Java Devices: Set-Top Boxes, Phones, Consoles
        1. PersonalJava
        2. JavaTV
        3. JavaPhone
        4. PingTel xpressa Phone
        5. Sharp NC-10 IP Phone
      3. Personal Digital Assistants (PDAs)
        1. J2ME PDA Profile
        2. PalmOS
        3. Microsoft Windows CE
          1. Siemens SIMpad SL4
          2. Siemens SX45
        4. Symbian EPOC
          1. Psion netBook (Series 7)
          2. Psion RevoPlus
        5. Sharp Zaurus SL-5000
        6. Other Linux Handhelds
        7. Micro Java Virtual Machines
          1. Javasoft's KVM for the Palm
          2. Javasoft's MIDP for the PalmOS
          3. Javasoft's PersonalJava for Windows CE
          4. IBM J9 VM
          5. Esmertec Jbed Micro Edition CDLC
          6. kAWT Extended KVM (xKVM)
          7. Kadasystems Kada VM
          8. MicroJBlend
          9. Jeode EVM
          10. NSIcom CrEme
          11. HP chaiVM for Pocket PC
          12. SAVAJE XE Operating System
          13. Transvirtual Kaffe
      4. Mobile Phones and Pagers
        1. Casio CdmaOne C452CA
        2. Ericsson R380
        3. Fujitsu F503i
        4. Hitachi CdmaOne C451H
        5. LG Telecom p510 (i-Book)
        6. Other LG Telecom Phones
        7. Matsushita/Panasonic P503i
        8. Matsushita/Panasonic P503iS
        9. Matsushita/Panasonic FOMA P2101V
        10. Mitsubishi D503i and D503iS
        11. Mitsubishi J-D05
        12. Motorola i85s
        13. Motorola i50sx
        14. Motorola Accompli 009 PIC
        15. Motorola, Accompli 008/6288
        16. Other Motorola Phones
        17. NEC N503i
        18. NEC FOMA N2001
        19. Nokia 9210 and 9290 Communicator
        20. RIM/iPaq Blackberry
        21. Samsung SCH-X130, SCH-X230, SCH-X350, and SCH-X350
        22. Sharp J-SH07
        23. Siemens SL45i (or 6688i)
        24. Sony SO503i
        25. Toshiba J-T06
      5. Low-End Java Devices: Smart Cards and Embedded Chips
        1. JavaCard
        2. EmbeddedJava
      6. Summary
    2. 3. Big Games, Small Screens
      1. Your Competition
        1. Things to Look For
        2. The Near Future
      2. WAP Games
        1. Wireless Games
          1. Sorcery
          2. Tanks
          3. Fight KO
          4. Code Breaker
          5. Mines
          6. Casino Games
          7. Popular Classics
          8. Wireless Pets
          9. Quiz Call and LMA Football Quiz
          10. Top Trumps
          11. Wentworth Golf
        2. Jamdat
          1. Gladiator
        3. PicoFun
          1. Lifestylers
          2. Picofun Football
          3. On the Green
          4. Wall Street Wizard
          5. Fight Arena
        4. Handy Games
          1. WAP Knights
          2. WAP Tanks
          3. WAP Massacre
          4. WAP Interpol
          5. WAP Crates
          6. WAP Girlfriends
        5. FunCaster.com
        6. Unplugged Games
          1. Void Raider
          2. Rags 2 Riches
          3. Word Trader
        7. nGame
          1. Alien Fish Exchange
          2. Carrier Force
          3. Chop Suey Kung Fu
          4. Data Clash
      3. i-mode Games
        1. Dwango's Turibaka Kibun
      4. SMS Games
        1. Fisupeli
        2. Blue Factory
        3. BotFighters by It's Alive
        4. Vizzavi Footie and Trivia
      5. J2ME MIDP Games
        1. Karl Hörnell's MIDP-Man
        2. HolyCowBoy's BlockBuster and HolyMoley
        3. Draw Poker
        4. Cocoasoft
          1. Axion
          2. i-Skiing
          3. Jerry the Cat: Indiana Jerrys
        5. RomeBlack's Mobile Internet Maze Game
        6. Sky Arts' Cube Game
        7. Jshape's M-Type and MIDP Street Fighter
        8. Spruce Team
        9. Red Team's Dope Wars
      6. J2ME Palm Games
        1. Torunda!
        2. Karl Hörnell's Iceblox and PalmWarp
        3. Hobbit's Let Me Alone
      7. iAppli Games
        1. Squiral Game
        2. Dwango's Samurai Romanesque
        3. Dwango's Challenge! The Hard-Boiled Way
        4. Sega
        5. Namco
        6. Capcom
        7. Bandai Networks
        8. Cybird's Mini Game Tengoku
        9. Hudson Soft
      8. What Are You Waiting For?
  6. II. Before, Between, and Beyond J2ME
    1. 4. Wireless Standards: How Data Goes To And Fro
      1. Wireless Networks
        1. First Generation (1G)
        2. Second Generation (2G)
        3. Second (and a Half) Generation (2.5G)
        4. Third Generation (3G)
      2. The Wireless Application Protocol (WAP)
        1. The WAP Protocol Stack
        2. WAP Architecture
        3. The Wireless Markup Language (WML)
          1. WML Basics
          2. A Game of Cards and Decks
          3. Anchors Away
          4. Text Formatting Tags
          5. Tables
          6. User Input Tags
            1. Input Fields
            2. Option Groups
            3. Check Boxes and Radio Buttons
            4. Field Sets
            5. Example
            6. The <do> Tag
            7. Variables
          7. Images
          8. Timers
        4. WMLScript
          1. Accessing WML Script
          2. WMLScript Example
      3. Server-Side WAP
        1. Server Configuration
        2. WAP and Java
          1. A Servlet Game Lobby
          2. Using JavaServer Pages (JSPs)
        3. Development Environment
      4. Handheld Device Markup Language (HDML)
        1. HDML Syntax
        2. Displays
        3. Activities
        4. Actions
        5. Hyperlinks
        6. Images
      5. WAP 2.0 and xHTML Basic
      6. Summary
    2. 5. Let's Talk: Instant Wireless Messaging
      1. Messaging And Gaming
      2. Short Message Service (SMS)
        1. SMS Specifics
          1. SMS Text Mode
          2. Protocol Description Unit (PDU) Mode
          3. Smart Messaging
          4. Unicode Messages
          5. Flash SMS
        2. Short Message Service Centers (SMSCs)
        3. Free SMS Service
      3. Actually Sending SMS Messages
        1. SMS Tools
      4. SMS and J2ME
        1. Sample Server Code
      5. Multimedia Messaging Service (MMS)
        1. Multimedia Message Service Centers (MMSC)
        2. Crack a SMIL
        3. Simple SMIL Example
        4. Enhanced Messaging Service (EMS)
      6. Summary
    3. 6. Wireless in Asia: i-mode and cHTML
      1. Using i-mode
      2. Compact HTML (cHTML)
        1. Character Sets
        2. Emoji
        3. cHTML Structure
        4. Standard cHTML Tags
        5. Input Forms
          1. The <Input> Tag
          2. Special Form Attributes
          3. The <Select> Tag
          4. The <TextArea> Tag
        6. The Anchor Tag
          1. Extended Anchor Tag Functions
        7. Images
        8. <Marquee>
      3. Development Tools
      4. Testing and Emulators
      5. Summary
    4. 7. The Wireless Landscape
      1. Bluetooth
        1. Bluetooth Protocols
        2. Bluetooth and Java
        3. Other Short-Range Applications
        4. Broadband's Promise
      2. Mobile Positioning
        1. How It All Works
        2. Forums and Associations
        3. Privacy
        4. Positioning Technologies
          1. Global Positioning System (GPS)
          2. Assisted GPS (A-GPS) and Differential GPS (DGPS)
          3. GSM Location Positioning
          4. Time Difference of Arrival
          5. Angle of Arrival
          6. Enhanced Observed Time Differential
          7. Radio Propagation
      3. m-Commerce
        1. Charging for Content
        2. Micro Java and Money
      4. Voice and Telephony
        1. VoiceXML
        2. VoiceXML Software
        3. Wireless Telephony Application Interface (WTAI)
      5. Unified Messaging (UM)
      6. Summary
  7. III. The Java 2 Micro Edition
    1. 8. J2ME Overview
      1. The Trinity of Java Platforms
      2. It's a Small World After All
        1. Using Java on Small Devices
        2. J2ME Rocks!
      3. Profiles and Configurations
        1. Major J2ME Configurations
        2. J2ME Profiles
        3. The Kilobyte Virtual Machine
        4. The Java Application Manager
        5. Packaging into a JAR File
      4. Connected in a Limited Way: The CLDC
        1. Security
        2. Pre-verifying
      5. The Mobile Profile
        1. MIDP in a Nutshell
        2. Earlier Profiles
      6. Summary
    2. 9. Creating a MIDlet
      1. Command-Line MIDlet Development
      2. Development Environments
        1. Wireless Toolkit
        2. Developing a MIDlet with the Wireless Toolkit
      3. Lifecycle of a MIDlet
      4. Displaying Stuff
        1. Working with Screens
        2. Forms
      5. Menus and Commands
      6. Creating Help and About Alert Screens
        1. The Alert Class
        2. Splash Screens
      7. Global Properties
        1. Getting Application Properties
        2. Getting System Properties
        3. Creating a Global Cache Class
      8. Summary
    3. 10. Making the Most of Limited Resources
      1. The Limitations
        1. Processor Paucity
        2. Memory Madness
        3. Video Vex
        4. Processors of the Future
      2. Memory Limitations
        1. Working Memory
          1. Memory Fragmentation
          2. Memory Matters
        2. Storage Memory
      3. Displays
      4. Breaking Through the Limitations
        1. Detecting the Minimum Speed
        2. Frame Rate
        3. Multiple Display Support
        4. Black and White World
      5. Summary
    4. 11. Making the Most of It: Optimizations
      1. A Limited World
      2. Making Code Optimal
        1. Code Size Optimizations
        2. Making Code Faster
        3. Decreasing Memory
        4. Device Availability
        5. Network Performance
      3. Code Size Reductions
        1. Obfuscators and Name-Shortening
        2. The Object-Oriented Dilemma
        3. Image Size Reduction
      4. Speeding Up the Code
        1. Dealing with the Garbage Collector
        2. The Constructorless Way
          1. Math Classes
        3. Static Methods
        4. The Fast-Draw
      5. Using Less Memory
        1. String Versus StringBuffer
        2. Arrays Versus Vector and Hashtable
      6. Power Consumption
      7. Summary
    5. 12. Multithreaded Game Programming
      1. Threads
      2. Extending the Thread Object
      3. Implementing the Runnable Interface
      4. Thread Priorities
      5. Thread States
      6. Synchronizations and Deadlocks
      7. wait() and notify()
      8. Timers
      9. Making Threads Better
      10. Summary
  8. IV. Let the Games Begin!
    1. 13. High-Level Graphical User Interfaces
      1. The Screen Class
      2. Forms and Alerts
      3. Lists
        1. List Types
        2. Choices, Choices
      4. Text Boxes
      5. Items
        1. Item State Listening
        2. Choices
        3. Dates
        4. Progress Meters
        5. StringItems
        6. ImageItems
        7. Text Inputs
      6. Tickers
      7. Additional Libraries
      8. Summary
    2. 14. Working with Graphics: Low-Level Graphical User Interfaces
      1. The Canvas Class
        1. Canvas Events
        2. Custom Commands
        3. Creating a Game Key and Pointer Handler
        4. Handling Touch Screens
      2. Painting on the Screen
        1. Working with Colors
        2. Stroke Types
        3. Drawing Lines
        4. Drawing Rectangles
        5. Drawing Rounded Rectangles
        6. Drawing Arcs
        7. Fonts
        8. Drawing Strings
      3. Drawing Images
        1. The Image Class
        2. Clipping
        3. Translating
        4. Double Buffering
      4. Summary
    3. 15. Entering the Land of Sprites
      1. Sprites
        1. Sprite Properties
        2. Animating Frames
        3. The Sprite Class
      2. Image Files
        1. Loading Included Images
        2. Loading Images Over the Network
        3. Image Size Reduction
        4. Drawing the Sprites
      3. Collision Detection
        1. Basic Collision Detection
      4. Creating Child Sprites
        1. Building the Player Sprite
        2. Opponents
      5. Image Transparency
        1. Drawing by Pixels
        2. Drawing a Sprite's Chunks
        3. Implementation of Image Transparency
      6. Summary
    4. 16. Managing Your Sprites
      1. Networked Game Components
        1. Downloading Images
        2. Downloading Other Media Types
      2. Advanced Collision Detection
        1. Solution 1: Multiple Levels
        2. Solution 2: Multiple Areas
      3. The Sprite Manager
        1. Drawing Optimizations
        2. Enhancing Sprite Collision
      4. Summary
    5. 17. Sprite Movement
      1. Floating-Point in J2ME
        1. Cheating the System
      2. Game Initialization
      3. Movement
        1. The Movement Routine
      4. Piecing It All Together
        1. Handling Collision Detection
        2. Endgame: Losing or Winning
        3. The Final Game Thread
      5. Summary
    6. 18. J2ME Audio Basics
      1. Sounds Are (Barely) Possible!
      2. Summary
    7. 19. Be Persistent: MIDP Data Storage
      1. RecordStore Overview
      2. RecordStore in Practice
        1. addRecord()
        2. getRecord()
        3. setRecord()
        4. deleteRecord()
        5. getLastModified()
        6. getNextRecordID()
        7. getNumRecords()
        8. getSize()
        9. getSizeAvailable()
        10. deleteRecordStore()
        11. EnumerateRecords()
          1. RecordStore Exceptions
        12. The Game's New Methods
        13. Writing the Code
          1. The MIDlet Changes
      3. More RecordStore Joy
      4. Summary
    8. 20. Connecting Out: Wireless Networking
      1. J2ME Networking Overview
      2. MIDP Networking
        1. A Little Info About HTTP
          1. HTTP Setup Mode
          2. Making the HTTP Connection
          3. Closing Out
        2. HTTP Example
          1. Response Code
          2. Reading In Data
          3. Closing Down Cleanly
        3. Working Around HTTP's Limitations
          1. Multiple Connections
          2. The Power of the Proxy
      3. Setting Up Your Game Server
      4. Data Format
        1. Doing Your Own Packing
        2. XML
        3. Encoding with DataOutputStream and DataInputStream
      5. Making a Multiplayer Car Racing Game
        1. Design the System
        2. Special Considerations
          1. Polling
          2. Keeping HTTP Connections Alive
          3. Session Tracking
        3. The Messages
        4. Weaknesses
        5. The Client Side
        6. The Server Side
          1. The Game Data
          2. The Servlet
        7. Playing the Game
      6. Summary
  9. V. J2ME Extensions
    1. 21. PersonalJava, Connected Device Configuration, and Other Micro Java Blends
      1. Connected Device Configuration (CDC)
        1. J2ME Foundation Profile
        2. The Personal Profile
      2. PersonalJava
        1. PersonalJava APIs
        2. Double Buffering
          1. Input Without a Mouse
          2. Dealing with Unsupported Features
          3. The Timer API
        3. Developer Tools
          1. PersonalJava Emulation Environment
          2. JavaCheck
          3. Nokia's PersonalJava Development Environment
        4. MIDP Plug-In for PersonalJava
        5. PersonalJava Design Considerations
      3. PDA Profile
      4. Java Game Profile
      5. The J2ME Multimedia Profile
      6. Summary
    2. 22. iAppli: Micro Java with a Twist
      1. The Architecture of It All
        1. Provisioning
          1. The ADF File
          2. The Provisioning Process
          3. Updating Applications
          4. i-mode Extension Tags
        2. Priorities, Priorities
      2. iAppli: Like MIDP, But Not Quite
        1. User Interface
          1. Low-Level UI
          2. Graphics
          3. High-Level UI
            1. Label
            2. TextBox
            3. ListBox
            4. Ticker
            5. VisualPresenter
            6. Button
            7. Dialog Boxes
          4. Handling Events
            1. Process Event on Canvas
            2. KeyListener on a Panel
            3. Component Listener
            4. SoftKeyListener
          5. Graphics and Sound
            1. Displaying an Image
            2. Playing Music
            3. Listening to Your Music
        2. Networking and Input/Output
          1. HTTP Connections
          2. ScratchPad
      3. Developing iApplis
      4. Summary
    3. 23. Siemens Game API
      1. Getting Set Up
        1. Compiling
        2. Running with the Emulator
        3. Running on the Actual Phone
        4. Download Your Applet Over the Air
      2. The Game SDK Overview
      3. Images and Sprites
        1. Creating an Extended Image
        2. Blitting
      4. Graphic Objects
      5. Sprites
        1. Creating and Masking a Sprite
        2. Sample Code
      6. TiledBackground
        1. The Tiles
        2. The Tile Background
      7. Flashing
      8. Good Vibrations
      9. Music, Sweet Music
        1. Melodies
          1. Composing Like a Virtuoso
          2. Playing the Melody
      10. GSM Functions
        1. Making a Call
        2. Accessing the Phone Book
        3. SMS Messages
      11. Input Output
        1. Sending and Receiving Data
        2. Saving and Loading Files
      12. Summary
  10. VI. Micro Racer
    1. 24. Micro Racer: Putting It All Together
      1. The Bad News
      2. The Good News
      3. Putting Together the Pieces
        1. Adding Weapons
        2. Better Enemies: Artificial Intelligence
        3. Better Control
        4. Adding Power-Ups
        5. Tying In the Game with the Data Store
        6. Tying In the Offline Game with the Online Garage
          1. Changing GarageClient
          2. Changing the Game Client
          3. Adding the Garage to the Game Menu
          4. Now You're Online!
        7. Future Work
      4. One Game Running Everywhere
        1. The Magic of Interfaces
      5. Summary
  11. VII. Appendixes
    1. A. Low-Level GUI Classes
      1. Game Classes
      2. javax.microedition.lcdui.AlertType
      3. javax.microedition.lcdui.Command
      4. javax.microedition.lcdui.Display
      5. javax.microedition.lcdui.Displayable
      6. javax.microedition.lcdui.Canvas
      7. javax.microedition.lcdui.Screen
      8. javax.microedition.lcdui.Alert
      9. javax.microedition.lcdui.Form
      10. javax.microedition.lcdui.List
      11. javax.microedition.lcdui.TextBox
      12. javax.microedition.lcdui.Font
      13. javax.microedition.lcdui.Graphics
      14. javax.microedition.lcdui.Image
      15. javax.microedition.lcdui.Item
      16. javax.microedition.lcdui.ChoiceGroup
      17. javax.microedition.lcdui.DateField
      18. javax.microedition.lcdui.Gauge
      19. javax.microedition.lcdui.ImageItem
      20. javax.microedition.lcdui.StringItem
      21. javax.microedition.lcdui.TextField
      22. javax.microedition.lcdui.Ticker
    2. B. MIDP 1.1
      1. Main Packages
      2. java.io Class Hierarchy
      3. java.io Interface Hierarchy
      4. java.lang Class Hierarchy
      5. java.lang Interface Hierarchy
      6. java.util Class Hierarchy
      7. java.util Interface Hierarchy
      8. javax.microedition.io Class Hierarchy
      9. javax.microedition.io Interface Hierarchy
      10. javax.microedition.lcdui Class Hierarchy
      11. javax.microedition.lcdui Interface Hierarchy
      12. javax.microedition.midlet Class Hierarchy
      13. javax.microedition.rms Class Hierarchy
      14. javax.microedition.rms Interface Hierarchy
    3. C. Siemens Game API
      1. Game Classes
        1. com.siemens.mp.game.Light
        2. com.siemens.mp.game.MelodyComposer
        3. com.siemens.mp.game.ExtendedImage
        4. com.siemens.mp.game.GraphicObject
        5. com.siemens.mp.game.Sprite
        6. com.siemens.mp.game.TiledBackground
        7. com.siemens.mp.game.GraphicObjectManager
        8. com.siemens.mp.game.Melody
        9. com.siemens.mp.game.Sound
        10. com.siemens.mp.game.Vibrator
      2. Siemens GSM Classes
        1. com.siemens.mp.gsm.Call
        2. com.siemens.mp.gsm.PhoneBook
        3. com.siemens.mp.gsm.SMS
      3. Input/Output Classes
        1. com.siemens.mp.io.Connection
        2. com.siemens.mp.io.File
        3. public interface ConnectionListener
    4. D. The iAppli API
      1. Packages
      2. com.nttdocomo.io Interfaces
      3. com.nttdocomo.io Interfaces
      4. com.nttdocomo.lang
      5. com.nttdocomo.net
      6. com.nttdocomo.ui
      7. com.nttdocomo.ui Interfaces
      8. com.nttdocomo.util
      9. com.nttdocomo.util Interfaces
      10. IApplication