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 />

■ ■Tip I recommend that you use the PNG digital imaging format for your <strong>Java</strong> 8 games. This is a professional<br />

image-compositing format, and your games will essentially be a real-time sprite-compositing engine, so you will need<br />

to use PNG32 imagery.<br />

PNG has two truecolor file versions: PNG24, which cannot be used in image compositing, and PNG32, which<br />

carries an alpha channel used to define transparency.<br />

I recommend PNG for your games because it has a decent image compression algorithm and because it is a<br />

lossless image format. This means that PNG has great image quality as well as reasonable levels of data compression<br />

efficiency, which will make your game distribution file smaller. The real power of the PNG32 format lies in its ability to<br />

composite with other game imagery, using transparency and antialiasing (via its alpha channel).<br />

Digital Image Resolution and Aspect Ratio: Defining Image Size and Shape<br />

As you probably know, digital imagery is made up of 2D (two-dimensional) arrays of pixels (“pixel” stands for picture<br />

[pix] element [el]). The sharpness of an image is expressed by its resolution, which is the number of pixels in the image<br />

width (or W, sometimes referred to as the x axis) and height (or H, sometimes referred to as the y axis) dimensions.<br />

The more pixels an image has, the higher its resolution. This is similar to how digital cameras work, as the more<br />

megapixels in an image capture device (called a camera CCD), the higher the image quality that can be achieved.<br />

To find the total number of image pixels, multiply the width pixels by the height pixels. For instance, a wide video<br />

graphics array (VGA) 800 × 480 image contains 384,000 pixels, which is exactly three-eighths of a megabyte. This is<br />

how you would find the size of your image, both in terms of kilobytes (or megabytes) used and height and width on<br />

the display screen.<br />

The shape of a digital image asset is specified using the image aspect ratio. Aspect ratio is the width:height ratio<br />

for the digital image and defines the square (1:1 aspect ratio) or rectangular (also known as widescreen) digital image<br />

shape. Displays featuring a 2:1 (widescreen) aspect ratio, such as 2,160 × 1,080 resolution, are now available.<br />

A 1:1 aspect ratio display (or image) is always perfectly square, as is a 2:2 or 3:3 aspect ratio image. You might<br />

see this aspect ratio on a smart watch, for instance. It is important to note that it is the ratio between these two width<br />

and height (x and y) variables that defines the shape of an image or screen, not the actual numbers themselves.<br />

An aspect ratio should always be expressed as the smallest pair of numbers that can be achieved (reduced)<br />

on either side of the colon. If you paid attention in high school while you were learning about the lowest common<br />

denominator, then an aspect ratio will be very easy for you to calculate. I usually do aspect ratio calculation by<br />

continuing to divide each side of the colon by two. For example, if you take the SXGA 1,280 × 1,024 resolution, half of<br />

1,280 × 1,024 is 640 × 512, and half of 640 × 512 is 320 × 256; half of 320 × 256 is 160 × 128, half of that again is 80 × 64,<br />

half of that is 40 × 32, and half of that is 20 × 16; half of 20 × 16 is 10 × 8, and half of that gives you the 5 × 4 aspect ratio<br />

for SXGA, which would be signified by using a colon between the two numbers, as in a 5:4 aspect ratio.<br />

Digital Image Color Theory and Color Depth: Defining Precise Image Pixel Colors<br />

The color values for each digital image pixel can be defined by the amount of three different colors, red, green, and<br />

blue (RGB), which are present in different amounts in every pixel. Consumer electronics display screens leverage<br />

additive colors, in which wavelengths of light for each RGB color channel are added together creating 16.8 million<br />

different color values. Additive color is used in liquid crystal display (LCD), light-emitting diode (LED), and organic<br />

light-emitting diode (OLED) displays. It is the opposite of subtractive color, which is used in printing. To show you the<br />

different results, under a subtractive color model, mixing red with green (inks) will yield purple colors, whereas in an<br />

additive color model, mixing red with green (light) creates a vibrant yellow coloration. Additive color can provide a<br />

much broader spectrum of colors than subtractive color.<br />

www.it-ebooks.info<br />

107

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

Saved successfully!

Ooh no, something went wrong!