Computer Science 486 Mobile and Internet Game Development

Study Guide :: Unit 4

Third Android Game Development—Asteroids

Overview

This chapter will guide you through developing a game, Asteroids, using the OpenGL ES 2 graphics library. OpenGL ES 2 is the second major version of Open Graphics Library (OpenGL) for embedded systems like mobile phones. It is the mobile incarnation of OpenGL for desktop systems.

Use of OpenGL ES 2 library allows the Asteroids game to draw and animate hundreds of objects at a time on Android devices. This graphics library takes the drawing efficiency of the game to a much higher level without introducing many implementation complexities. The movement of different objects and collision detection are also greatly enhanced compared to the previous two games (as covered in units 2 and 3).


Learning Objectives

After completing this unit, you will be able to:

  • Describe the level concepts of OpenGL ES 2.
  • Achieve rate of 60 frames per second (fps) or better, even on old hardware.
  • Introduce some advanced features, such as shooter with waves of progressive difficulty, twinkling stars, rapid-fire gun, and spinning asteroids.
  • Implement advanced multiphase collision detection.

Learning Activities

  • Read Unit 4 notes.
  • Read the following chapters in the textbook, Android Game Programming by Example:
    • Asteroids at 60 fps with OpenGL ES 2
    • Move and Draw with OpenGL ES 2
    • Things That Go Bump, Part II
  • Read the review questions below in this unit and use the course discussion forum to:
    • Post your answer to any one of the review questions below.
    • Comment on another student’s posted answer.
    • Answer any questions posed to you.
  • Do the unit exercise, discuss it with your Academic Expert, and share the experience with your peers on the discussion board.

Lesson Notes

  1. Asteroids at 60 fps with OpenGL ES 2

    This lesson describes an introductory-level 2D game design using an efficient graphics library, OpenGL ES 2. This lesson basically shows how to draw and render different graphics objects with OpenGL ES 2 and integrate the drawing system into the Android game engine. By the end of the lesson, we will have a working engine that draws an Asteroids-style spaceship to the screen.

  2. Move and Draw with OpenGL ES 2

    This lesson describes how to integrate sound and user-control systems in the Asteroids game from the previous projects (as covered in units 2 and 3). This lesson also describes how some advanced-level features, such as game border, twinkling star system, spinning asteroids, a heads-up display (HUD), progressively difficult levels, and a rapid-fire gun to the player’s spaceship are added in the Asteroids game.

  3. Things That Go Bump, Part II

    This chapter describes the technique to introduce multi-level collision detection in the Asteroids game. The math required to detect collisions with the irregularly shaped spinning asteroids is made simple and implemented into the game engine. By the end of the chapter, we will have the third and final fully playable Asteroids game.


Review Questions

  1. What is OpenGL ES? How do we port the library to embedded systems such as mobile phones using Android? What are the main advantages and disadvantages of OpenGL ES in game programming?
  2. What are the differences between FrameBuffer and RenderBuffer in OpenGL ES? How can you use them in mobile-game development?
  3. How do you construct curved surfaces using polygon approximations in OpenGL ES?
  4. How do you draw a sphere in OpenGL ES without using gluSphere?
  5. How do you rotate an object about a point in OpenGL ES (Android)?
  6. What are shaders in openGL and what do we need them for? How are shaders implemented in the Asteroids game in the textbook?
  7. Explain the OpenGL rendering pipeline. What class is responsible for performing the rendering operation in the Asteroids game in the textbook? How does this class perform rendering in the game (class structure, operations, etc.)?
  8. How has the GameObject class been made OpenGl-friendly in the Asteroids game in the textbook?
  9. How are twinkling stars implemented in the Asteriods game in the textbook? Can you think any other efficient solution for this implementation?
  10. How is collision detection performed in the Asteroids game? Can you identify some pros and cons of this collision-detection technique?

Unit Exercise

  1. Implement the Asteroids game by following the instructions and the codes provided in the textbook. Review and analyze the codes and different functionalities of the Asteroids game for a better understanding. Post your experience and discuss items that you found useful in the respective unit forum.