O'Reilly logo

Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition by Jim Holliday - Editor, Aleksi Uotila, Mark Patel, Jyri Huopaniemi, Jim Van Peursem, Antero Taivalsaari, Roger Riggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

12.7. Sample Code: A Simple Game

This example illustrates how the APIs discussed in this chapter can be used to form a simple game. The user controls a car that is always moving forward at a constant speed and can be turned 90 degrees clockwise or counterclockwise. The object of the game is to drive around the track and collect as many coins as possible without hitting any of the walls. (See Figure 12.16 on the next page.)

Figure 12.16. A screen shot from the simple game

The car is implemented using a Sprite that can be rotated in 90-degree increments using the appropriate transform. Special frame sequences are used to show just the first frame ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required