This page is optimized for mobile devices, if you would prefer the desktop version just click here

0.6 Slick0160: using the draw and drawflash methods.

Learn about using the draw, drawCentered, and drawFlash methods of the Image class.

Table of contents

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

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.
<< Chapter < Page Page > Chapter >>

Read also:

OpenStax, Anatomy of a game engine. OpenStax CNX. Feb 07, 2013 Download for free at https://legacy.cnx.org/content/col11489/1.13
Google Play and the Google Play logo are trademarks of Google Inc.
Jobilize.com uses cookies to ensure that you get the best experience. By continuing to use Jobilize.com web-site, you agree to the Terms of Use and Privacy Policy.