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

You may have noticed that there are three identical X,Y data point coordinate values for every point, except<br />

for the starting and ending point, for which we have data point pairs instead of data point triplets. If you recall<br />

back in Table 16-1, the only SVG command that uses triplet (three) X,Y data point pairs is the C, or Cubic Bezier<br />

(Spline) Curve. Sure enough, as you see in Figure 16-15, right under the M (moveto) opening SVG command is the<br />

C command. This explains why GIMP put three data points in each point in your polygon. The reason all the data<br />

point triplets have the same value is because we checked the polygon option in GIMP. This puts the spline curve<br />

control handles “away” or out of sight, directly on top of the X,Y data point. This defines zero curvature, or the square<br />

polygon structure seen in Figure 16-14.<br />

Let’s export the SVG data with the triplets removed, which is shown in Figure 16-15, and see what the result looks<br />

like in GIMP, using our newfound Import Path work process, primarily for learning purposes, as we are not quite<br />

finished with the optimization work process.<br />

Figure 16-15. Remove duplicate point data for those points in the interior of the collision polygon, to further optimize<br />

Save the XML data shown in Figure 16-15 as sprite1svghandintegerxmloptimized.txt and then use the same<br />

Import Path work process, shown in Figures 16-12 and 6-13, to import this further optimized SVG data set into GIMP.<br />

As you can see in Figure 16-16, removing those cubic Bezier curve control handles from the data set also removes the<br />

polygonal nature of your collision polygon. So, we will need to do some further work on our SVG data to correct this.<br />

www.it-ebooks.info<br />

359

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

Saved successfully!

Ooh no, something went wrong!