Android SDK Compatibility

Appportunity

Build your own Android App Dev Empire

Get Instant Access

As a developer you may ask yourself about the SDK compatibility of the code in this book. This is an important question as new versions of the Android SDK come out frequently. By the time of this writing, Google released the Android SDK version 2.0. The code in this chapter has been tested with the following versions of the Android SDK:

The bottom line is that the code in this book will run in any version of the SDK from 2.0 to 1.0, and that was my intention all along.

SDK Changes for Version 1.6

Virtually nothing has changed from versions 1.5 to 1.6 of the platform when it comes to game development. For a detailed list of API changes in version 1.6, see

http://developer.android.com/sdk/RELEASENOTES.html.

This book has a well-balanced layout of pure Java and hybrid games, divided as follows:

Chapter 1

This chapter provides the first step to set up a Linux system for hybrid game compilation, including fetching the Android source, extracting device system libraries, setting up a custom compilation toolchain, custom compilation scripts, plus details on setting up the Eclipse IDE for use throughout the rest of the book.

Chapter 2

In this chapter you will learn how to combine Java and C code in an elegant manner by building a simple Java application on top of a native library. You will learn exciting concepts about the Java Native Interface (JNI) and the API used to combine Java and C in a single unit, including how to load native libraries, how to use the native keyword, how to generate the JNI headers, plus all about method signatures, Java arrays vs. C arrays, invoking Java methods, compiling and packing the product, and more.

Chapter 3

This chapter is the first in a series to explore pure Java gaming with a real-world game dubbed Space Blaster. The goal of this game is to maneuver (using your finger tips or the keyboard) a space ship through a field of meteors. This chapter will teach you how to build custom XML-based linear layout, how to use an abstract class and timer tasks to simulate a simple game loop, how to invalidate views within a non-UI thread, how to load sprites and sounds from the project resources, plus drawing techniques such as sprite animations, drawing simple objects, and setting style and color using the Paint object.

Chapter 4

Pure Java games continue in Chapter 4 with the arcade classic Asteroids. This chapter will teach you all about drawing polygon sprites on the Android canvas. This is a somewhat difficult technique due to the lack of polygon support in the Android API. The chapter relies on the high portability of the Java language to bring polygon code from the J2SE API into the Android API to ultimately create Asteroids. As you may have noticed, this is a mostly Polygon-based game. Other interesting topics include game life cycle steps, initialization, draw, and update physics, responding to key and touch events, plus testing on the device emulator.

Chapter 5

This chapter deals with 3D graphics with OpenGL. It presents a neat trick I stumbled on by coincidence that allows for mixing OpenGL API calls in both Java and C. This concept is illustrated by using the 3D cubes sample provided by Google to demonstrate OpenGL in pure Java and hybrid modes. This trick could open a new frontier of 3D development for Android with the potential to bring a large number of 3D PC games to the platform with enormous savings in development costs and time.

Chapter 6

This is the first chapter in a series of two, which are my personal favorites of this book. Here it brings the godfather of all PC 3D shooters to the Android platform—Wolfenstein 3D. Who would have thought that a PC game like this one could be brought to an Android mobile device with minimal effort? This chapter demonstrates how Java and C can coexist harmoniously and includes topics such as the basic game architecture (showing how the Java and C components fit together), resource handlers for sound, music, key and touch events, how to use JNI to cascade graphics information, video buffers, and sound/music requests back to Java, plus compilation and testing.

Chapter 7

Chapter 7 takes things to the next level with the ground-breaking game for the PC—Doom. Doom is arguably the greatest 3D game ever created and opened new frontiers in 3D graphics. The ultimate goal of this chapter is not to describe the game itself, but to show you how easy it is to bring a complex PC game like Doom to the Android platform. The proof? Doom is 100+K lines of C code and brought to Android with less than 200 lines of extra JNI API calls, plus the Java code required to build the mobile UI. This chapter shows that you don't have to translate 100K lines of C into Java but simply marry these two powerful languages in an elegant application. Consider the potential savings in development time and costs! This chapter is a must-read.

Download at WoweBook.com

Was this article helpful?

0 0

Post a comment