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 ...
Get Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.