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 importimport means to make the classes and/or packages available in this program fang2.transformers.BounceInsideRectangleTransformer;
07 importimport means to make the classes and/or packages available in this program fang2.transformers.KeyboardTransformer;
08 importimport means to make the classes and/or packages available in this program fang2.transformers.VelocityTransformer;
09
10 // FANG Demonstration program: PolygonSprite and LineSprite
11 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 BounceHex
12 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
13 // Called before game loop: make hex and line over it and add
14 @Override
15 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
16 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);
17 hex.setScale(0.5);
18 hex.setLocation(0.5, 0.5);
19 hex.setColor(getColor("orange"));
20 addSprite(hex);
21
22 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);
23 line.setColor(getColor("yellow green"));
24 addSprite(line);
25
26 VelocityTransformer velocity =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor VelocityTransformer(-45, 1.0);
27 BounceInsideRectangleTransformer bounce =this assignment operator makes the left side equal to the right side
28 newnew is used to create objects by calling the constructor BounceInsideRectangleTransformer(velocity);
29 hex.addTransformer(bounce);
30 }close braces end code blocks and must match an earlier open brace
31 }close braces end code blocks and must match an earlier open brace
32
33 //Uploaded on Mon Mar 29 21:41:23 EDT 2010
|
Download/View scg/ch03/BounceHex.java