<< Chapter < Page Chapter >> Page >

A complete listing of this program is provided in Listing 32 near the end of the module.

The program named GM01test03

This is a 3D update of the 2D program named GM01test04 discussed above.

A comparison of programming requirements

Basically all that was required to perform the update was to specify 3D classes from the game-math library in place of the 2D classes used in the 2Dversion of the program. In some cases, this in turn required that argument lists for constructors and methods be expanded from two dimensions to threedimensions. Just about everything else took care of itself.

A comparison of these two programs illustrates the value of the game-math library named GM01 and the ease with which you can switch back and forth between 2D and 3D programming when using the library.

A comparison of visual behavior

The visual behavior of this 3D version, as shown in Figure 3 , is more realistic than the 2D version. This is particularly true when the prey objectgets in the middle of the predators and the display is showing vectors. In the 2D version, a predator is constrained to swing around only in the plane of thescreen. However, in this 3D version, a predator is not subject to that constraint and is free to swing around in the most appropriate way as the preyobject passes by.

This constraint causes the motion in the 2D version to be less fluid than the motion in the 3D version. This can best be demonstrated with only one predatorbecause that makes it easy to see the behavior of an individual predator as the animation is running.

No swimming in formation

One very interesting thing that I have noticed is that unlike the 2D version, the predators in this 3D version don't seem to have a tendency to form up andswim in formation while chasing the prey object. This may be because they have more options in terms of avoiding collisions while giving chase. However, thatis pure speculation on my part since I don't know why the predators tend to swim in formation in the 2D version anyway. (It is also possible that the predators form into a 3D formation, which isn't visually obvious in the 2Dprojection.)

Won't explain the code

As is the case with the earlier program named GM01test04 , once you understand the code in the program named GM01test08 , you should have no difficulty understanding the code in this program. Therefore, I won't explainthe code in this program. I included this program and the earlier 2D version in this module mainly to illustrate the differences between 2D and 3D from both avisual viewpoint and programming viewpoint.

A complete listing of this program is provided in Listing 33 near the end of the module.

The program namedStringArt04

This program animates the behavior of the earlier program named StringArt03 that I explained in an earlier module. See the comments at the beginning of that program for a description of both programs.

The only significant difference in the behavior of the two programs is that this program slows the rotation process down and animates it so that the usercan see it happening in slow motion. Of course, quite a few changes were required to convert the program from a static program to an animated program.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Game 2302 - mathematical applications for game development. OpenStax CNX. Jan 09, 2016 Download for free at https://legacy.cnx.org/content/col11450/1.33
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Game 2302 - mathematical applications for game development' conversation and receive update notifications?

Ask