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 8 ■ Creating Your Actor Engine: Design the Characters for Your Game and Define Their Capabilities<br />

The InvinciBagel Sprite Images: Visual Action States<br />

Besides designing the optimal Actor Engine classes to use to implement characters, treasure, and obstacles in a game,<br />

the other important thing to optimize is the main character for the game, and the different states of animation that<br />

a character will move between, based on the movement of the character by the player. From a memory optimization<br />

standpoint, the fewer image frames that we can accomplish all of this in, the better. As you can see in Figure 8-2, I will<br />

provide all of the InvinciBagel character motion states using only nine different sprite image assets; some of these can<br />

be used in more than one way: for instance, by using the pX and pY variables, which will allow us to rotate these sprite<br />

frames around any pivot point that we choose. An example of this is center pivot point placement for the FLY state,<br />

seen in the middle of Figure 8-2, which gives us a take-off (fly up), flying, and landing (fly down) simply by rotating this<br />

image 50 degrees clockwise (to a horizontal orientation) to 100 degrees clockwise (tilting to fly down, instead of up).<br />

Figure 8-2. The nine primary character motion sprites for the InvinciBagel character that will be used during the game<br />

Even though we are providing offset and pivot point capabilities in our sprite Actor Engine abstract classes, that<br />

doesn’t mean that we should not make sure that our motion sprite image states are well synchronized with each<br />

other. This is so that we do not routinely have to use these pivot or offset capabilities to get good visual results. This is<br />

what I term sprite registration, and involves positioning the different sprite states optimally relative to each other.<br />

Some examples of sprite registration between sprite frames that will be used with each other can be seen in<br />

Figure 8-3. For instance, the starting to run imageStates[1] sprite should start its run cycle with the same foot position<br />

as a standing (or waiting) imageStates[0] sprite, as seen on the left side of Figure 8-3. Also, the running imageStates[2]<br />

sprite should keep its body portion as still as possible, relative to the imageStates[1] starting to run sprite. A preparing<br />

to land imageStates[6] sprite should change foot positioning realistically relative to the landed imageStates[7] sprite.<br />

Figure 8-3. Sprite registration (alignment) to make sure the transition motion is smooth<br />

What you want to do to optimize sprite registration, relative to all of the other sprites, is to put all of your digital<br />

image sprites into the same square 1:1 aspect ratio resolution image format, and place them all in layers in a digital<br />

image compositing software package, such as GIMP or Photoshop. Then use the move tool and nudge (single pixel<br />

movements using arrow keys on keyboard) each sprite into position, relative to whichever two layers you have<br />

visibility (toggled on/off using the eye icon on the left of each layer) turned on for. The result is shown in Figure 8-3.<br />

www.it-ebooks.info<br />

167

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

Saved successfully!

Ooh no, something went wrong!