Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1
Chapter 18 ■ 3D Gameplay DesiGn: CreatinG your Game Content usinG Gimp anD Java

Later during this chapter, we will generate the 20 game board square content generation XCF files that
will accumulate digital image content that the Java code will eventually select from for each game board
square that the initial random spin selects for gameplay (i.e., the five squares attached to the randomly
selected quadrant). This approach allows us to randomize the quadrant as well as the content for each of the
quadrant’s game board squares.
Finally, let’s use the GIMP File ➤ Export As menu sequence and save this new diffuse texture map in
the /NetBeansProjects/JavaFXGame/src folder as gamesquare1bird1.png. Notice in your file manager
that this texture map is less than 80KB in size, which is considerably larger than your 1KB default texture.
It will always be the case that high-quality 24-bit content will add to the data footprint of the application.
If you wanted to optimize this data footprint further, you should use the Image ➤ Mode ➤ Indexed menu
sequence in GIMP to turn your image into an 8-bit indexed color image and use Generate Optimum Palette
(256 colors) with Floyd-Steinberg Dithering. This will reduce gamesquare1bird1.png to 27.4KB in size, as
it is now a PNG8 image, with good-quality results.
How you name these files is important because your gameplay Java code, which we will start to
write in the next chapter, will make random decision logic based on these name components. Obviously,
gamesquare1 (the first part of the name) will define which gamesquare (Q1S1 through Q4S5) will be
mapped. The second part is a subclassification. In this case, it’s “bird” but could also be “feline” or “canine”
or “bovine” and so forth. The last part is how many selections the random number generator has to select
from, so if you have bird1 through bird5 for game board square 1, your Random object will select from 0
through 5 inclusively. In this way, as you add new content (in collections of 20, or one image subject for each
game board square), you can increment your Random object’s random number–generating Java code to add
a new maximum random number (zero through the upper selection boundary) as you add content.


Figure 18-14. Select the 256 texture map composite tab, select the layer under the red square, and select Edit ➤
Paste as Layer

Free download pdf