From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch02;
02
03 importimport means to make the classes and/or packages available in this program fang2.core.Game;
04 importimport means to make the classes and/or packages available in this program fang2.sprites.RectangleSprite;
05 importimport means to make the classes and/or packages available in this program fang2.sprites.StringSprite;
06
07 /**
08 * Draws two rectangles as axes across the center of the screen (shows
09 * off some odd color names) and then labels the origin, center, and
10 * extent points on the screen.
11 */
12 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects ScreenCoords
13 extendsextends means to customize or extend the functionality of a class Game {open braces start code blocks and must be matched with a close brace
14 /**
15 * Set up the sprites to display on the screen. Five sprites are
16 * created and added to the game.
17 */
18 @Override
19 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup() {open braces start code blocks and must be matched with a close brace
20 RectangleSprite vertical =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(0.05, 1.0);
21 vertical.setColor(getColor("pink", 128));
22 vertical.setLocation(0.5, 0.5);
23 addSprite(vertical);
24
25 RectangleSprite horizontal =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor RectangleSprite(1.0, 0.05);
26 horizontal.setColor(getColor("cornflower blue", 128));
27 horizontal.setLocation(0.5, 0.5);
28 addSprite(horizontal);
29
30 // labels: string (in quotes), height (in screens)
31 StringSprite origin =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("(0.0, 0.0)");
32 origin.setLineHeight(0.05);
33 origin.setColor(getColor("white"));
34 origin.setLocation(0.1, 0.05);
35 addSprite(origin);
36
37 StringSprite extent =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("(1.0, 1.0)");
38 extent.setLineHeight(0.05);
39 extent.setColor(getColor("white"));
40 extent.setLocation(0.9, 0.95);
41 addSprite(extent);
42
43 StringSprite center =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("(0.5, 0.5)");
44 center.setLineHeight(0.05);
45 center.setColor(getColor("white"));
46 center.setLocation(0.63, 0.55);
47 addSprite(center);
48 }close braces end code blocks and must match an earlier open brace
49 }close braces end code blocks and must match an earlier open brace
50
51 //Uploaded on Mon Mar 29 21:39:52 EDT 2010
|
Download/View scg/ch02/ScreenCoords.java