Table of contents
- Preface
- Preview
- General background information
- Discussion and sample code
- Run the programs
- Summary
- What's next?
- Miscellaneous
- Complete program listing
Preface
This module is one in a collection of modules designed to teach you about the anatomy of a game engine.
Although the modules in this collection will concentrate on the Java game library named Slick2D, theconcepts involved and the knowledge that you will gain is applicable to different game engines written in different programming languages as well.
An earlier module titled A first look at Slick2D bitmap graphics introduced you to the use of bitmap graphics in Slick2D. The purpose of this module isdig a little deeper into the use of bitmap graphics
Viewing tip
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the imagesand listings while you are reading about them.
Figures
- Figure 1 . Output from the program named Slick0160a.
- Figure 2 . One output from the program named Slick0160b.
- Figure 3 . Another output from the program named Slick0160b.
Listings
- Listing 1 . Beginning of the Slick0160a class.
- Listing 2 . The main method.
- Listing 3 . The init method.
- Listing 4 . The render method.
- Listing 5 . Draw the top four images.
- Listing 6 . Draw three more images.
- Listing 7 . Draw image based on its center.
- Listing 8 . Draw a flipped copy.
- Listing 9 . Beginning of the Slick0160b class.
- Listing 10 . The update method.
- Listing 11 . Beginning of the render method.
- Listing 12 . The large flashing spider.
- Listing 13 . Source code for Slick0160a.java.
- Listing 14 . Source code for Slick0160b.java.
Preview
Bitmap graphics are used in a variety of ways in game and simulation programming. Therefore, I will present and explain two programs that digmore deeply into the use of bitmap graphics in Slick2D.
The program named Slick0160a
The first program named Slick0160a calls the draw method of the Image class several times in succession toillustrate some of the options available with the draw method. This program also illustrates flipping an image. The output from thisprogram is shown in Figure 1 .
Figure 1 . Output from the program named Slick0160a. |
---|
|
The program named Slick0160b
The second program named Slick0160b illustrates the use of the drawFlash method to draw an image in silhouette and to cause the silhouette to switchback and forth between two or more colors. The program draws several spiders in silhouette. It causes a large spider toflash back and forth between a white silhouette and a blue silhouette. A screen shot of the output from the program while the large spider is in its white state is shown in Figure 2 .
Figure 2 . One output from the program named Slick0160b. |
---|
|