28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 16 ■ Collision Detection: Creating SVG Polygons for the Game Actors and Writing Code to Detect Collision<br />

Table 16-1. (continued)<br />

SVG Command Name Symbol Type Parameter Description<br />

shortandsmoothcurve s Relative X,Y, X,Y Draws a cubic Bezier curve from current<br />

point to next point<br />

quadratic Bezier curve Q Absolute X,Y, X,Y Draws a quadratic Bezier curve (current<br />

point to next point)<br />

quadratic Bezier curve q Relative X,Y, X,Y Draws a quadratic Bezier curve (current<br />

point to next point)<br />

short quadratic Bezier T Absolute X,Y Draws a short quadratic Bezier (current point<br />

to next point)<br />

short quadratic Bezier t Relative X,Y Draws a short quadratic Bezier (current point<br />

to next point)<br />

elliptical arc A Absolute rX, rY, Rot Draws an elliptical arc from current point to<br />

next point<br />

elliptical arc a Relative rX, rY, Rot Draws an elliptical arc from current point to<br />

next point<br />

The best way to see how to use the powerful SVG data “path drawing” commands is to get down to learning the<br />

work process for creating SVG data-based collision polygon paths. We will learn how to do this using GIMP 2.8.14,<br />

using a “quick and dirty” approach, which lets GIMP do 100% of the path creation work. After that, we’ll learn another<br />

way to do this by hand using GIMP. A second approach gives you 100% of the path creation control. At the end of this<br />

SVG topic, I will also show you how to use another dedicated collision and physics development tool called PhysEd<br />

from an innovative game development software tools company, located in Ulm, Germany, called CodeAndWeb GmbH.<br />

Creating and Optimizing Collision Data: Using GIMP<br />

Fortunately for us, the popular open source digital image editing software package called GIMP, currently at version<br />

2.8.14, has enough Path capabilities, and the ability to export this as SVG datasets, to allow the software to be used<br />

as a full-fledged collision polygon creation tool. The GIMP software supports paths using a Path Tool (shown as an<br />

old-fashioned fountain pen tip next to a curve data point with Bezier handles coming out of it), which you can see<br />

in Figure 16-1 (second icon from the left in the second row of the Toolbox Icons). The reason GIMP supports paths,<br />

as it is not generally a vector (path-based) software package, but instead a raster (pixel-based) software package,<br />

is because the ability to create a path and then “convert” it to a selection area is a very useful one to the digital<br />

image compositing artisan. In fact, we will be using GIMP’s ability to do just the opposite of this: that is, convert an<br />

algorithmically created selection set into path data, which will form the foundation of our fully automated, “quick and<br />

dirty” SVG Path data creation process. We will take a look at this first, since it is fast, simple, and effective (but “data<br />

heavy”). Let’s get started by launching GIMP, and using the File ➤ Open process to open the sprite1.png PNG32<br />

digital image asset that is in your project /src folder. As you can see in Figure 16-1, I have zoomed into the image. This<br />

allows me to see the collision data path (initially, this will be a selection) that we’re about to create using the GIMP<br />

Toolbox.<br />

www.it-ebooks.info<br />

345

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

Saved successfully!

Ooh no, something went wrong!