28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5 ■ An Introduction to Game Design: Concepts, Multimedia, and Using Scene Builder<br />

Figure 5-1. How new media assets are implemented, using Scene Graph through the <strong>Java</strong>FX API in <strong>Java</strong> 8 via NetBeans<br />

Because you need to have a technical foundation before using any of these types of new media elements in a<br />

<strong>Java</strong> 8 game design and programming pipeline, I am going to go over basic concepts for each of these four new media<br />

areas, beginning with digital imaging and vector illustration.<br />

Digital Imaging Concepts: Resolution, Color Depth, Alpha, Layers<br />

<strong>Java</strong>FX (and therefore <strong>Java</strong>8) supports a significant number of popular digital imaging file (data) formats, which<br />

gives game designers a ton of flexibility. Some of these have been around forever, such as CompuServe’s graphics<br />

interchange format (GIF) and the Joint Photographic Experts Group (JPEG) format. Some <strong>Java</strong>FX graphics file<br />

formats are more modern, such as portable network graphics (PNG; pronounced “ping”), which is the file format<br />

that you will be using for your games, as it yields the highest quality level and supports image compositing. All these<br />

mainstream digital image file formats supported in <strong>Java</strong> are also supported in HTML5 browsers, and because <strong>Java</strong><br />

applications can be used with HTML applications and web sites, this is a very logical synergy indeed!<br />

The oldest CompuServe GIF format is the lossless digital image file format. It is termed lossless because it does<br />

not throw away image data to achieve better compression results. The GIF compression algorithm is not as refined<br />

(powerful) as that of the PNG format, and GIF only supports indexed color, which is how it obtains its compression<br />

(smaller file size). If your game image assets are already created with the GIF format, you will be able to use them with<br />

no problem (other than a less efficient image compression algorithm and no compositing capability) with your <strong>Java</strong> 8<br />

game applications.<br />

The most popular digital imaging file format that <strong>Java</strong> 8 (<strong>Java</strong>FX) supports is JPEG, which uses a “truecolor”<br />

color depth, instead of an indexed color depth, as well as what is termed lossy digital image compression, in which<br />

the compression algorithm “throws away” image data so that it can achieve a smaller file size (the image data are lost<br />

forever, unless you are smart and save your original image!).<br />

If you magnify a JPEG image after compression, you will see a discolored area (effect) that clearly was not<br />

present in the original imagery. The degraded area or areas in the image are commonly referred to as compression<br />

artifacts. This will only occur in lossy image compression and is common with JPEG (and Moving Picture Experts<br />

Group [MPEG]) compression.<br />

106<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!