From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch03;
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.LineSprite;
05 importimport means to make the classes and/or packages available in this program fang2.sprites.PolygonSprite;
06
07 // FANG Demonstration program: PolygonSprite and LineSprite
08 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 HexAndLine
09 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
10 // Called before game loop: make hex and line over it and add
11 @Override
12 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
13 PolygonSprite hex =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(6);
14 hex.setScale(0.5);
15 hex.setLocation(0.5, 0.5);
16 hex.setColor(getColor("orange"));
17 addSprite(hex);
18
19 LineSprite line =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor LineSprite(0.1, 0.9, 0.9, 0.1);
20 line.setColor(getColor("yellow green"));
21 addSprite(line);
22 }close braces end code blocks and must match an earlier open brace
23 }close braces end code blocks and must match an earlier open brace
24
25 //Uploaded on Mon Mar 29 21:41:19 EDT 2010
|
Download/View scg/ch03/HexAndLine.java