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.OvalSprite;
05 importimport means to make the classes and/or packages available in this program fang2.transformers.VelocityTransformer;
06 importimport means to make the classes and/or packages available in this program fang2.transformers.WrapTransformer;
07
08 // FANG Demonstration program: OvalSprite,
09 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 Circle
10 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
11 // Called before game loop: create named oval and add
12 @Override
13 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
14 OvalSprite oval =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.2, 0.2);
15 oval.setColor(getColor("cornflower blue"));
16 oval.setLocation(0.5, 0.5);
17 addSprite(oval);
18
19 OvalSprite o2 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(0.05, 0.05);
20 addSprite(o2);
21 // velocity is (facing in degrees, speed in screens/second);
22 // 0.0 degrees is positive x-axis, rotation goes counterclockwise
23 VelocityTransformer velocityTransformer =this assignment operator makes the left side equal to the right side
24 newnew is used to create objects by calling the constructor VelocityTransformer(25.0, 1.0);
25 oval.addTransformer(velocityTransformer);
26 o2.addTransformer(velocityTransformer);
27 // wrapping means wrapping from left to right or top to bottom
28 WrapTransformer wrapTransformer =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor WrapTransformer();
29 oval.addTransformer(wrapTransformer);
30 o2.addTransformer(wrapTransformer);
31 }close braces end code blocks and must match an earlier open brace
32 }close braces end code blocks and must match an earlier open brace
33
34 //Uploaded on Mon Mar 29 21:42:12 EDT 2010
|
Download/View scg/ch03/Circle.java