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 16 ■ Collision Detection: Creating SVG Polygons for the Game Actors and Writing Code to Detect Collision<br />

To find out the data footprint optimization, simply divide these numbers into each other. If you divide 97 by 1605<br />

(97/1605=0.0604) you find that 97 is 6% of 1605, giving you a 94% reduction in data footprint. If you divide 1605 by 97<br />

(1605/97=16.546) it means you have reduced the file by 16.546 times, giving a 16.55X data footprint reduction. These<br />

are the inverse (1/x) of each other on the calculator, so you can look at it from either direction. So 1605 bytes is 1,655%<br />

more data than 97 bytes, or 97 bytes is 6% (or 94% less data) of 1605 bytes. Any way that you look at it, you have just<br />

saved your game a whole lot of memory, processing, and JAR file data footprint, and that is only for one of the sprites!<br />

Remember that optimizing your collision polygon to use more than 16 times less memory as well as 16 times less<br />

CPU processing overhead can be very significant to the smoothness of your game play once you implement collision<br />

detection in your game logic, which we are going to do after we take a look at CodeAndWeb’s PhysEd tool.<br />

Creating and Optimizing Physics Data: Using PhysEd<br />

I want to take a couple of pages to show you an alternative to GIMP that incorporates both physics and collision into a<br />

unified game development tool offering that is extremely affordable relative to all that it does for game development.<br />

PhysicsEditor, or PhysEd (or PE) is from CodeAndWeb GmbH, a company owned by another Apress author, Andreas<br />

Loew, who writes about iOS Game <strong>Development</strong>. Let’s take a quick look at how we would define our sprite’s collision<br />

polygon using this professional game development tool, and then we will be ready to get to collision detection coding.<br />

Install and launch PE using the green cube PE icon, and use the Import Sprite button shown in Figure 16-21 to open<br />

up your sprite1.png file, and use the zoom slider at the bottom of the screen to zoom in 600%, just like we did in GIMP.<br />

Figure 16-21. Launch PhysicsEditor and use the Add Sprites button to open the sprite1.png file and zoom into it 600%<br />

363

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

Saved successfully!

Ooh no, something went wrong!