Beginning Mobile Phone Game Programming

Book description

Build several fully functional games as well as a game engine to use for programming cell phone and mobile games with Beginning Mobile Phone Game Programming! The included CD provides the tool, code and graphics necessary to complete all exercises covered in the chapters. Beginning Cell Phone Game Programming demystifies wireless game programming by providing clear, practical lessons using the J2ME Game API. You will learn how to use the most popular mobile programming language, Java, to build compact games that can run on any Java-enabled device, including mobile phones, pagers and handheld computers. You will also learn to add a splash screen, create a demo mode, keep track of high scores, and test, debug, and deploy your games.

Topics covered include:

  • How to construct a game engine to drive mobile games.

  • How to use Java 2 Micro Edition (J2ME) and the Java Game API to get the most performance out of your mobile games.

  • How to implement sprite animation and control interactions among moving sprites.

  • How to play sound effects and music in mobile games.

  • How to take advantage of wireless networks to build mobile multiplayer games.

  • How to design and develop a variety of different games spanning several video games genres.

  • Table of contents

    1. Copyright
      1. Dedication
    2. About the Author
    3. Acknowledgments
    4. We Want to Hear from You!
    5. Reader Services
    6. Introduction
      1. How This Book Is Structured
      2. What You’ll Need
    7. I. Getting Started with Mobile Game Programming
      1. 1. Games on the Go
        1. Essentials of Mobile Gaming
          1. The First Mobile Phone Game
          2. The Market for Mobile Games
          3. The Culture of Mobile Games
          4. The Bleeding Edge of Mobile Gaming
        2. Getting to Know Mobile Platforms
          1. Java 2 Micro Edition (J2ME)
          2. Binary Runtime Environment for Wireless (BREW)
          3. Symbian
          4. Windows Mobile Smartphone
        3. Java As a Mobile Game Platform
          1. What Is Java?
          2. Why Java?
          3. Java and Mobile Game Programming
            1. Graphics and Animation
            2. Responding to Mobile User Input
            3. Playing Sound in Mobile Games
            4. Mobile Networking
        4. A Quick J2ME Primer
          1. Configurations and the Connected Limited Device Configuration (CLDC)
          2. Profiles and the MIDP
            1. Assessing the MIDP Hardware Requirements
            2. Examining the MIDP Software Requirements
        5. Summary
        6. Field Trip
      2. 2. Mobile Java Game Development Basics
        1. Game Design Basics
          1. Coming Up with the Basic Idea
          2. Developing the Storyline
          3. Establishing the Play Modes
        2. A J2ME Game Development Primer
        3. Getting to Know the J2ME Wireless Toolkit
          1. Using KToolbar
          2. Managing MIDlet Game Projects
          3. Building a Game MIDlet
          4. Testing a Game MIDlet
        4. The J2ME Emulator and Physical Devices
        5. Summary
        6. Field Trip
      3. 3. Constructing a Mobile Game Skeleton
        1. Exploring the J2ME APIs
          1. The CLDC API
          2. The MIDP API
        2. Understanding MIDlets
          1. Inside a MIDlet
            1. MIDlet Life Cycle
            2. MIDlet Commands
            3. The Display, Screens, and Canvases
          2. The Basics of MIDlet Development
        3. Building the Skeleton Example Program
          1. Writing the Program Code
          2. Preparing the MIDlet for Distribution
          3. Building and Testing the Finished Product
        4. Summary
        5. Extreme Game Makeover
    8. II. Mobile Game Programming Essentials
      1. 4. Mobile Game Graphics 101
        1. Mobile Graphics Basics
          1. Understanding the Graphics Coordinate System
          2. Learning the Basics of Color
        2. Working with Graphics in J2ME
          1. Drawing Graphics Primitives
            1. Lines
            2. Rectangles
            3. Arcs
          2. Drawing Text
          3. Drawing Images
        3. Building the Olympics Example Program
          1. Writing the Program Code
          2. Testing the Finished Product
        4. Building the Slideshow Example Program
          1. Writing the Program Code
          2. Testing the Finished Product
        5. Summary
        6. Extreme Game Makeover
      2. 5. Using Sprite Animation
        1. Understanding Animation
          1. Animation and Frame Rate
          2. Making the Move to Computer Animation
          3. 2D Versus 3D Animation
        2. Analyzing 2D Sprite Animation
          1. Frame-Based Animation
          2. Cast-Based Animation
            1. Seeing Through Objects with Transparency
            2. Adding Depth with Z-Order
            3. Detecting Collisions between Objects
        3. Applying Sprite Animation to Mobile Games
        4. Working with the Layer and Sprite Classes
        5. Achieving Smooth Animation with the GameCanvas Class
        6. Building the UFO Example Program
          1. Writing the Program Code
          2. Testing the Finished Product
        7. Summary
        8. Extreme Game Makeover
      3. 6. Handling Mobile User Input
        1. Assessing Mobile Game Input
        2. Handling Key Input with the GameCanvas Class
        3. Revisiting the Sprite Class
          1. Detecting Sprite Collisions
          2. Working with Frame-Animated Sprites
        4. Building the UFO 2 Example
          1. Writing the Program Code
          2. Testing the Finished Product
        5. Summary
        6. Extreme Game Makeover
      4. 7. Henway: Paying Tribute to Frogger
        1. The Scoop on Henway
        2. Designing the Game
        3. Developing the Game
          1. Writing the Game Code
        4. Testing the Game
        5. Summary
        6. Extreme Game Makeover
      5. 8. Making Noise with Tones
        1. Sound and Mobile Games
        2. A Tonal Sound and Music Primer
        3. Querying a Phone for Its Audio Capabilities
        4. Playing Tones in Mobile Games
          1. Playing Individual Tones
          2. Playing a Tone Sequence
        5. Building the UFO 3 Example Program
          1. Writing the Program Code
          2. Testing the Finished Product
        6. Summary
        7. Field Trip
      6. 9. Playing Digitized Sound and Music
        1. A Digitized Sound Primer
        2. Getting to Know Wave Sounds
        3. Creating and Editing Wave Sounds
        4. Revisiting the Player Interface
        5. Playing Wave Sounds in Mobile Games
          1. Playing a Wave from a JAR File
          2. Playing a Wave from a URL
        6. Feeling the Music with MIDI
        7. Playing MIDI Music in Mobile Games
          1. Playing a MIDI Song from a JAR File
          2. Playing a MIDI Song from a URL
        8. Building the Henway 2 Example Game
          1. Writing the Game Code
          2. Testing the Finished Product
        9. Summary
        10. Field Trip
    9. III. Virtual Worlds and Mobile Game Intelligence
      1. 10. Creating Tiled Game Layers
        1. What Is a Tiled Layer?
        2. Creating Maps for Tiled Layers
          1. Using the Mappy Map Editor
          2. Using the Tile Studio Map Editor
          3. Formatting Map Information for Games
        3. Working with the TiledLayer Class
          1. Creating a Tiled Layer
          2. Moving and Drawing a Tiled Layer
        4. Building the Wanderer Example Program
          1. Writing the Program Code
          2. Testing the Finished Product
        5. Summary
        6. Field Trip
      2. 11. Managing Multiple Game Layers
        1. Dealing with Multiple Game Layers
        2. Working with the LayerManager Class
        3. Animating Tiled Layers
        4. Building the Wanderer 2 Example Program
          1. Designing the Tiled Layer Maps
            1. The Background Map
            2. The Barrier Map
          2. Writing the Program Code
          3. Testing the Finished Product
        5. Summary
        6. Extreme Game Makeover
      3. 12. High Seas: A Game for the Pirate in You
        1. The Scoop on High Seas
        2. Designing the Game
          1. Putting Together the Water Map
          2. Putting Together the Land Map
        3. Developing the Game
          1. Creating a Drift Sprite
          2. Declaring the Member Variables
          3. Assembling the start() Method
          4. Piecing Together the update() Method
          5. Drawing the Game Screen
          6. Starting a New Game
          7. Safely Placing Sprites
        4. Testing the Game
        5. Summary
        6. Extreme Game Makeover
      4. 13. Teaching Games to Think
        1. The Least You Need to Know About AI
        2. Exploring Types of Game AI
          1. Roaming AI
            1. Chasing
            2. Evading
            3. Patterned Roaming
          2. Behavioral AI
          3. Strategic AI
        3. Developing an AI Strategy
        4. Teaching Sprites to Think...Sort Of
          1. Designing the Chase Sprite
          2. Coding the Chase Sprite
        5. Building the High Seas 2 Example Game
          1. Writing the Program Code
          2. Testing the Finished Product
        6. Summary
        7. Extreme Game Makeover
    10. IV. Taking Advantage of the Wireless Network
      1. 14. Mobile Game Networking Essentials
        1. Multiplayer Game Basics
          1. Turn-Based Games
          2. Event-Based Games
        2. Network Game Problems and Solutions
          1. State Synchronization
          2. Input Synchronization
          3. A Hybrid Solution
        3. Communicating over a Network with Sockets
          1. Stream Sockets
          2. Datagram Sockets
        4. Network Programming and J2ME
          1. Creating Datagram Packets
          2. Sending Datagram Packets
          3. Receiving Datagram Packets
        5. Building the Lighthouse Example
          1. Designing the Client and Server
          2. Writing the Program Code
            1. The Lighthouse Client and Server
            2. The Lighthouse Canvas
            3. The Lighthouse MIDlet
          3. Testing the Finished Product
        6. Summary
        7. Field Trip
      2. 15. Connect 4: A Classic Game Goes Wireless
        1. The Scoop on Connect 4
        2. Designing the Game
          1. Graphics and User Interface
          2. Game Logic
          3. Networking
        3. Developing the Game
          1. The Connect 4 Client and Server
          2. The Connect 4 Game Canvas
          3. The Connect 4 Game State
        4. Testing the Game
        5. Summary
        6. Field Trip
      3. 16. Debugging and Deploying Mobile Games
        1. Game Debugging Basics
          1. Single-Stepping Code
          2. Watching Variables
          3. Using Breakpoints
        2. Game Debugging Strategies
          1. Bug Prevention
            1. Getting Explicit with Parentheses and Precedence
            2. Avoiding Hidden Member Variables
            3. Making the Most of Exception Handling
          2. Bug Detection
            1. Taking Advantage of Standard Output
            2. Tracing the Call Stack
        3. Choosing a Debugger
        4. Deploying Mobile Games
          1. Understanding Over-the-Air Provisioning
          2. Preparing Your Game for Deployment
          3. Tweaking Your Web Server
        5. Testing OTA Provisioning with KToolbar
        6. Summary
        7. Field Trip
    11. V. Sprucing Up Your Games
      1. 17. Optimizing Mobile Java Games
        1. Understanding Mobile Game Optimization
          1. Optimizing for Maintainability
          2. Optimizing for Portability
          3. Optimizing for Size
          4. Optimizing for Speed
        2. General Mobile Game Optimization Tips
          1. Reducing Memory Usage
            1. Avoiding Objects Whenever Possible
            2. When You Do Use Objects, Recycle Them
            3. Cleaning Up After Yourself
          2. Minimizing Network Data
          3. Eliminating Unnecessary Graphics
        3. Java Code Optimization Tricks
          1. Compiling Without Debug Information
          2. Eliminating Unnecessary Evaluations
          3. Eliminating Common Subexpressions
          4. Taking Advantage of Local Variables
          5. Expanding Loops
          6. Code Shrinking and Obfuscation
        4. Profiling Your Mobile Game Code
        5. Monitoring Mobile Game Memory Usage
        6. Putting Mobile Game Optimization into Perspective
        7. Summary
        8. Extreme Game Makeover
      2. 18. Space Out: Paying Tribute to Space Invaders
        1. The Scoop on Space Out
        2. Designing the Game
        3. Developing the Game
          1. Creating a Moving Sprite
          2. Declaring the Member Variables
          3. Assembling the start() Method
          4. Piecing Together the update() Method
          5. Drawing the Game Screen
          6. Starting a New Game
          7. Adding Aliens, Missiles, and Explosions
        4. Testing the Game
        5. Summary
        6. Extreme Game Makeover
      3. 19. Keeping Track of High Scores
        1. The Importance of Logging Your Achievements
        2. Getting to Know the Java RMS
          1. Understanding Records and Record Stores
          2. Exploring the RecordStore Class
        3. Preparing High Score Data for Storage
        4. Building the Space Out 2 Example Game
          1. Designing the Game Enhancements
          2. Writing the Game Code
          3. Testing the Finished Product
        5. Summary
        6. Field Trip
    12. VI. Appendixes
      1. A. Java Game API Reference
        1. The GameCanvas Class
          1. Member Constants
          2. Constructor
          3. Methods
        2. The Layer Class
          1. Methods
        3. The Sprite Class
          1. Member Constants
          2. Constructors
          3. Methods
        4. The TiledLayer Class
          1. Constructor
          2. Methods
        5. The LayerManager Class
          1. Constructor
          2. Methods
      2. B. Mobile Game Programming Resources
        1. Micro Dev Net
        2. J2ME Gamer
        3. J2ME.org
        4. Forum Nokia’s Mobile Games Community
        5. Wireless Developer Network
        6. GameDev.net
        7. Gamasutra
        8. Game Developer Magazine
        9. Gamelan
        10. JavaWorld
        11. The Official Java Website
      3. C. Creating Graphics for Mobile Games
        1. Assessing Game Graphics
          1. Determining the Game Screen Size
          2. Reaching the Target Audience
          3. Establishing a Game Setting and Mood
          4. Adhering to a Graphics Style
        2. Exploring Graphics Tools
          1. Image Alchemy
          2. Paint Shop Pro
          3. Graphic Workshop
        3. Creating and Editing Graphics
          1. Line-Art Graphics
          2. 3D Rendered Graphics
          3. Scanned Photography and Video-Captured Graphics
          4. Background Graphics and Textures
          5. Animated Graphics
        4. Finding Graphics
    13. Java Programming Primer
      1. Hello, World!
      2. Tokens
        1. Identifiers
        2. Keywords
        3. Literals
          1. Integer Literals
          2. Floating-Point Literals
          3. Boolean Literals
          4. Character Literals
          5. String Literals
        4. Operators
        5. Separators
        6. Comments and Whitespace
      3. Data Types
        1. Integer Data Types
        2. Floating-Point Data Types
        3. Boolean Data Type
        4. Character Data Type
      4. Blocks and Scope
      5. Arrays
      6. Strings
      7. Expressions and Operators
        1. Operator Precedence
        2. Integer Operators
          1. Unary Integer Operators
          2. Binary Integer Operators
          3. Relational Integer Operators
        3. Floating-Point Operators
        4. Boolean Operators
        5. String Operators
        6. Assignment Operators
      8. Control Structures
        1. Branches
          1. if-else Branch
          2. switch Branch
        2. Loops
          1. for Loop
          2. while Loop
          3. do-while Loop
      9. Object-Oriented Programming and Java
      10. Working with Java Classes
        1. Declaring Classes
        2. Deriving Classes
        3. Overriding Methods
        4. Overloading Methods
        5. Access Modifiers
          1. The Default Access Modifier
          2. The public Access Modifier
          3. The protected Access Modifier
          4. The private Access Modifier
        6. The static Modifier
        7. The final Modifier
        8. Abstract Classes and Methods
      11. Creating Java Objects
        1. The Constructor
        2. The new Operator
      12. Object Destruction
      13. Packages
        1. Declaring Packages
        2. Importing Packages
        3. Class Visibility
      14. Interfaces
        1. Declaring Interfaces
        2. Implementing Interfaces

    Product information

    • Title: Beginning Mobile Phone Game Programming
    • Author(s):
    • Release date: November 2004
    • Publisher(s): Sams
    • ISBN: 9780768683783