Thank you for visiting Blazing Games

Compass

One feature that I personally think that all 3D games need is a compass or compass like component. While I certainly understand the argument that in the real-world you don't always have a compass on you, the real-world is also far less disorienting than a 3D rendered view on the computer screen. If you really were going into some strange caves, forest, or abandoned temple you would probably have some tool for orienting yourself. About the only time you wouldn't is if you mysteriously found yourself in the above places. While that sounds like the background story for Coffee Quest, I am nice and gave the player a compass because my goal is to entertain the player not to frustrate them.

Coffee Quest is a step-based game so turning in the game moves the player 90 degrees at a time. This means that there are only four compass directions in the game. These are the cardinal directions north south, east and west. Four directions means four different images. While the four images could be loaded separately, I use a technique known as image strips.

The concept of the image strip is a simple one. The different images are made to be the same size and each image is considered a frame. The frames are then put together into a single image file to form a strip (horizontal or vertical). Doing this has the advantage that all the images are in a single file so multiple image files don't have to be loaded.

Image strips are easy to implement in Java. In 1.1 and later versions of Java, you can take advantage of the advanced versions of drawImage.

drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)

Coffee Quest, however, was originally written for Java 1.0 so the technique that was used was a bit more complicated. I end up using the CropImageFilter class to create a new image that is a cropped version of the source image.

Previous page
Chapter 4 Page 2

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2009 Blazing Games Inc. All Rights Reserved