Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 24 ■ Optimizing game assets and COde, and game prOfiling Using netBeans


We will be taking a look at some of those Java code optimizations in a later section of the chapter on
Java 9 game code optimization ideas. First, let’s finish implementing your 8-bit indexed image assets in your
game and play it to see if there is any visual difference between the indexed-color PNG8 assets and the
true-color PNG24 image assets.


Implementing Indexed-Color Imagery: Adding a Path


Changing image assets from true color to indexed color is as easy as adding the /8bit path to your
populateQuadrant() methods and setupQSgameplay methods. You don’t have to do this to the
loadImageAssets() and resetTextureMaps() methods because those methods use texture maps that are not
indexed, as they are already small (a few kilobytes) and can remain as true-color images. The reason for this
is because they contain no digital imagery, as these are the blank textures that are used to make the game
board look empty before each round of gameplay spin. I took a screenshot of the populateQuadrantOne()
method showing the added /8-bit path, as shown in Figure 24-24.


You will need to add this same /8bit path addition to the front of your digital image referencing in
your 20 methods that set up gameplay. These are named for each Quadrant (Q) and Square (S), as your
setupQSgameplay() methods, which I left at the end of the custom 40 methods and 2 required methods
(start() and main() Java methods).
I have taken a screenshot of the first setupQ1S1gameplay() method to show that I have installed the
/8bit path to the front of the digital image references. I did this so that your new 8-bit (indexed color) PNG8
digital imagery will be utilized as texture maps for the board game instead of the 24-bit true-color digital
imagery we have been using.
We are doing this so that we can test your game using the Run ➤ Project work process to see whether
there is any visual difference when the i3D game is played when using the 325 percent smaller indexed color
image instead of a true-color 24-bit PNG image. Figure 24-25 shows the first of the 20 methods that will have
to be “path modified” by adding an /8bit folder path addition to the front (head) of a digital image reference
name. To do this easily, copy the /8-bit path once and paste it 60 times in the populateQuadrant() methods
and 60 times in the setupQSgameplay() methods.


Figure 24-24. Add an /8bit path in front of the current image file name reference to point to your new indexed
imagery

Free download pdf