You are previewing Beginning Java SE 6 Game Programming, Third Edition.

Beginning Java SE 6 Game Programming, Third Edition

Cover of Beginning Java SE 6 Game Programming, Third Edition by Jonathan S. Harbour Published by Course Technology PTR
  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
      2. The Casual Games Market
      3. Installing and Configuring Java
      4. Your First Java Program
      5. What You Have Learned
      6. Review Questions
      7. On Your Own
    2. 2. Java Programming Essentials
      1. Java Applets and Applications
      2. The Java Language
      3. The Essence of Class
      4. What You Have Learned
      5. Review Questions
      6. On Your Own
    3. 3. Creating Your First Java Game
      1. About the Game Project
      2. Creating the Game
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
  6. II. Java Game Programming
    1. 4. Vector-Based Graphics
      1. Programming Vector Graphics
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
    2. 5. Bitmap-Based Graphics
      1. Programming Bitmapped Graphics
      2. Transparency
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
    3. 6. Simple Sprites
      1. Programming Simple Sprites
      2. Creating a Reusable Sprite Class
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
    4. 7. Sprite Animation
      1. Sprite Animation
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
    5. 8. Keyboard and Mouse Input
      1. Listening to the User
      2. Keyboard Input
      3. Mouse Input
      4. What You Have Learned
      5. Review Questions
      6. On Your Own
    6. 9. Sound Effects and Music
      1. Playing Digital Sample Files
      2. Playing MIDI Sequence Files
      3. Reusable Classes
      4. What You Have Learned
      5. Review Questions
      6. On Your Own
    7. 10. Timing and the Game Loop
      1. The Potency of a Game Loop
      2. Stepping Up to Threads
      3. What You Have Learned
      4. Review Questions
      5. On Your Own
  7. III. The Galactic War Project
    1. 11. Galactic War: From Vectors to Bitmaps
      1. Improving the Game
      2. What You Have Learned
      3. Review Questions
      4. On Your Own
    2. 12. Galactic War: Sprites and Collision Boxes
      1. Creating the Project
      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
      2. Enhancing Galactic War
      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
      2. Enhancing Galactic War
      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)
      2. Creating an HTML Host File for Your Applet
      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
O'Reilly logo

Chapter 5. Bitmap-Based Graphics

Java has a robust and feature-rich set of classes for working with 2D bitmap-based graphics (also known as raster graphics), allowing you to load and draw bitmaps very easily. Bitmaps are the keys to building a good 2D game with images rather than vector shapes.

Here are the key topics in this chapter:

  • Loading and drawing bitmap images

  • Applying transformations to bitmap images

  • Drawing opaque and transparent images

Programming Bitmapped Graphics

I mentioned before that there are many methods for drawing bitmap images in Java. Actually, most of those methods are found in the base Graphics class, while several more are found in Graphics2D. I think you will find the Graphics2D methods more useful, so we won’t spend any time ...

The best content for your career. Discover unlimited learning on demand for around $1/day.