0%

Book Description

BEGINNING JAVA SE 6 GAME PROGRAMMING, THIRD EDITION is a hands-on guide that is perfect for beginner-level game programmers who want to quickly and easily learn how to create games using the latest version of the Java SDK, Java 6. Written in simple language, the book teaches each new skill using engaging tutorials, followed by end-of-chapter questions and exercises to help reinforce what you've just learned. Each chapter builds upon the previous ones, allowing you to repeat and practice the techniques covered. You'll begin with the basics of writing a simple game using vector graphics, move on to utilizing Java's advanced library to add animation and sound effects, and end by creating a professional, sprite-based game full of interesting artwork and details that you can share with others on the web.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. About the Author
  4. Introduction
    1. What Will You Learn in This Book?
    2. What about the Programming Language?
    3. What IDE Should You Use?
    4. Conventions Used in This Book
    5. Companion Web Site Downloads
  5. I. Java for Beginners
    1. 1. Getting Started with Java
      1. Java and the Web
        1. Studying the Market
        2. Design Rules
      2. The Casual Games Market
        1. No Manual Required
        2. Casual Games
      3. Installing and Configuring Java
        1. Installing Java
        2. Configuring the Java Command-Line Compiler
        3. Java Version Numbers
        4. Java SE 6 Development Kit
        5. Java Development Environments
          1. Command Prompt/Shell
          2. TextPad
          3. NetBeans
          4. Eclipse
      4. Your First Java Program
        1. Java Application
        2. Java Applet
          1. TextPad Configuration
          2. Applet Web Container
        3. Creating a NetBeans Project
        4. Creating an Eclipse Project
        5. JFrame-Powered Application
      5. What You Have Learned
      6. Review Questions
      7. On Your Own
        1. Exercise 1
        2. Exercise 2
    2. 2. Java Programming Essentials
      1. Java Applets and Applications
        1. Web Server Technology Explained
        2. Hosting Java Applets
        3. Compiling Java Code
      2. The Java Language
        1. Java Data Types
          1. Integer Numbers
          2. Floating-Point Numbers
          3. Characters and Strings
          4. Booleans
          5. Arrays
      3. The Essence of Class
        1. The main Function
        2. Object-Oriented Programming
          1. Data Hiding
          2. Encapsulation
          3. Inheritance
          4. Polymorphism
      4. What You Have Learned
      5. Review Questions
      6. On Your Own
        1. Exercise 1
        2. Exercise 2
    3. 3. Creating Your First Java Game
      1. About the Game Project
      2. Creating the Game
        1. Creating the Project
        2. The BaseVectorShape Class
        3. The Ship Class
        4. The Bullet Class
        5. The Asteroid Class
        6. The Main Source Code File
          1. Applet init() Event
          2. Applet update() Event
          3. Drawing the Player’s Ship
          4. Drawing the Bullets
          5. Drawing the Asteroids
          6. Screen Refresh
          7. Thread Events and the Game Loop
          8. Game Loop Update
          9. Updating the Ship
          10. Updating the Bullets
          11. Updating the Asteroids
          12. Testing for Collisions
          13. Keyboard Events
          14. Calculating Realistic Motion
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
        1. Exercise 1
        2. Exercise 2
  6. II. Java Game Programming
    1. 4. Vector-Based Graphics
      1. Programming Vector Graphics
        1. Working with Shapes
        2. Working with Polygons
        3. Rotating and Scaling Shapes
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
        1. Exercise 1
        2. Exercise 2
    2. 5. Bitmap-Based Graphics
      1. Programming Bitmapped Graphics
        1. Loading and Drawing Images
        2. Applying Transforms to Images
      2. Transparency
        1. Opaque Images
        2. Transparent Images
        3. Working Some Masking Magic
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
        1. Exercise 1
        2. Exercise 2
    3. 6. Simple Sprites
      1. Programming Simple Sprites
        1. Basic Game Entities
        2. The ImageEntity Class
      2. Creating a Reusable Sprite Class
        1. Collision Testing
        2. Sprite Class Source Code
        3. Testing the Sprite Class
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
        1. Exercise 1
        2. Exercise 2
    4. 7. Sprite Animation
      1. Sprite Animation
        1. Animation Techniques
        2. Drawing Individual Frames
        3. Keeping Track of Animation Frames
        4. Testing Sprite Animation
        5. Encapsulating Sprite Animation in a Class
        6. Testing the New AnimatedSprite Class
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
        1. Exercise 1
        2. Exercise 2
    5. 8. Keyboard and Mouse Input
      1. Listening to the User
      2. Keyboard Input
        1. Listening for Keyboard Events
        2. Testing Keyboard Input
      3. Mouse Input
        1. Reading Mouse Motion
        2. Detecting Mouse Buttons
        3. Testing Mouse Input
      4. What You Have Learned
      5. Review Questions
      6. On Your Own
        1. Exercise 1
        2. Exercise 2
    6. 9. Sound Effects and Music
      1. Playing Digital Sample Files
        1. Getting Started with Java Sound
          1. Loading the Sound Clip
          2. Playing the Sound Clip
          3. Stopping the Sound Clip
          4. Handling Errors
          5. Wrapping Sound Clips
        2. Playing Sounds
      2. Playing MIDI Sequence Files
        1. Loading a MIDI File
        2. Playing Music
      3. Reusable Classes
        1. The SoundClip Class
        2. The MidiSequence Class
      4. What You Have Learned
      5. Review Questions
      6. On Your Own
        1. Exercise 1
        2. Exercise 2
    7. 10. Timing and the Game Loop
      1. The Potency of a Game Loop
        1. A Simple Loop
        2. Overriding Some Default Behaviors
        3. Feeling Loopy
      2. Stepping Up to Threads
        1. Starting and Stopping the Thread
        2. The ThreadedLoop Program
        3. Examining Multithreading
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
        1. Exercise 1
        2. Exercise 2
  7. III. The Galactic War Project
    1. 11. Galactic War: From Vectors to Bitmaps
      1. Improving the Game
        1. Generalizing the Vector Classes
          1. The New Asteroid Class
          2. The New Bullet Class
        2. The Main Source Code File: GalacticWar.java
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
    2. 12. Galactic War: Sprites and Collision Boxes
      1. Creating the Project
        1. The Galactic War Bitmaps
        2. The New and Improved Source Code
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
    3. 13. Galactic War: Squashed by Space Rocks
      1. Being Civilized about Collisions
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
    4. 14. Galactic War: Entity Management
      1. Adjusting to Event-Driven Programming
        1. Exploring the Class Library
        2. Building the New Game Class
          1. Encapsulating a Standard Java Applet
          2. Custom Game Events
          3. The Game Class Source Code
      2. Enhancing Galactic War
        1. Exploring the New Galactic War Source Code
          1. Game Loop Update and Screen Refresh
          2. Updating and Drawing Sprites
          3. Handling Sprite Collisions
          4. Keyboard and Mouse Events
          5. Asteroid Manipulation Methods
          6. Handling Multiple Key Presses
          7. Moving the Spaceship
          8. Firing Weapons
          9. Give Me Something to Blow Up!
          10. Additional Game Logic
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
    5. 15. Galactic War: Finishing the Game
      1. Let’s Talk about Power-Ups
        1. Ship and Bonus-Point Power-Ups
        2. Weapon Upgrades
          1. Standard Weapon
          2. Weapon Level Two
          3. Weapon Level Three
          4. Weapon Level Four
          5. Weapon Level Five
      2. Enhancing Galactic War
        1. New Sprite Types
        2. New Game States
        3. New Sprite Images
        4. Health/Shield Meters, Score, Firepower, and Game State Variables
        5. New Input Keys
        6. Sound and Music Objects
        7. Loading Media Files
        8. Game State Issue—Resetting the Game
        9. Detecting the Game-Over State
        10. Screen Refresh Updates
        11. Preparing to End
        12. Updating New Sprites
        13. Grabbing Power-Ups
        14. New Input Keys
        15. Spawning Power-Ups
        16. Making the Shield Work
        17. Making Use of Weapon Upgrade Power-Ups
        18. Tallying the Score
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
    6. 16. Galactic War: Web Deployment
      1. Packaging an Applet in a Java Archive (JAR)
        1. Using the jar.exe Program
          1. Creating a New JAR File
          2. Listing the Contents of a JAR File
          3. Extracting Files from a JAR File
          4. Updating a JAR File
          5. Manifest Files
        2. Packaging Galactic War in a Java Archive
          1. Reviewing the Project Files
          2. Building the Java Archive
      2. Creating an HTML Host File for Your Applet
        1. A Simple HTML File
        2. Testing the Deployed Applet Game
      3. What You Have Learned
      4. Review Questions
      5. Epilogue
  8. Chapter Quiz Answers
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Chapter 12
    13. Chapter 13
    14. Chapter 14
    15. Chapter 15
    16. Chapter 16
18.216.42.81