<< Chapter < Page Chapter >> Page >

The program named GM01test02

Because I made some changes to the existing 2D classes in the game-math library and added some new methods to some of the existing 2D classes, I feltthe need to write a program that would step through and test the behavior of most of the 2D methods in the library. That was the purpose of the programnamed GM01test02 .

This program produces both a graphic screen output and lots of text on the command-line screen. The graphic output is shown in Figure 2 .

Figure 2 Graphics output from the program named GM01test02.

Missing image.

Command-line output from the program named GM01test02

The command-line output is shown in Figure 3 .

Figure 3 . Command-line output from the program named GM01test02.

Test overridden toString of ColMatrix2D 1.5,2.5Test setData and getData of ColMatrix2D 4.55.5 Test equals method of ColMatrix2Dfalse trueTest add method of ColMatrix2D 9.0,11.0Test subtract method of ColMatrix2D 0.0,0.0Test toString method of Point2D 4.5,5.5Test setData and getData of Point2D 1.12.2 Test getColMatrix method of Point2D1.1,2.2 Test equals method of Point2Dfalse trueTest getDisplacementVector method of Point2D 1.5,2.54.5,5.5 3.0,3.0Test addVectorToPoint method of Point2D 1.5,2.57.0,9.0 Test toString method of Vector2D1.5,2.5 Test setData and getData methods of Vector2D4.5 5.5Test getColMatrix method of Vector2D 4.5,5.5Test equals method of Vector2D falsetrue Test add method of Vector2D4.5,5.5 -1.5,3.53.0,9.0 Test getLength method of Vector2D3.0,4.0 5.0Test toString method of Line2D Tail = 1.5,2.5Head = 4.5,5.5 Test setTail, setHead, getTail,and getHead methods of Line2D 4.5,5.51.5,2.5

Not too exciting

Neither the graphics output in Figure 2 nor the command-line output in Figure 3 are terribly exciting, and neither will mean much to you unless you are willing to examine the code and compare the output with the code.

Source code for the program named GM01test02

A complete listing of the program named GM01test02 is shown in Listing 27 near the end of the module.

Listing 3 shows two of the statements in the constructor for the GUI class in the program named GM01test02 . The call to the method named testUsingText produces the command-line output shown in Figure 3 , while the call to the method named drawOffScreen produces the graphic output shown in Figure 2 .

Listing 3 . Code in the constructor for the GUI class in the program named GM01test02.
//Perform tests using text. testUsingText();//Perform tests using graphics.drawOffScreen(g2D);

If you examine the source code for those two methods in Listing 27 , you will see that each of the methods contains calls to library methods for thepurpose of confirming that the library methods behave as expected. The code in most of those methods is straightforward and should not requirefurther explanation beyond the embedded comments in Listing 27 .

End of the discussion for the program named GM01test02

That concludes the discussion of the program named GM01test02 . You will find a complete listing of this program in Listing 27 .

The program named GM01test01

Code in the program named GM01test01 makes calls to library methods, which in turn make calls to the method named convert3Dto2D shown in Listing 1 . Because of the complexity of projecting 3D points onto a 2D screen for display, it will be useful to discuss the three library methods thatmake calls to the library method named convert3Dto2D . Those three methods are shown in the following list :

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