scg/ch05/AxisSnowman

From FANG

Jump to: navigation, search

01 package scg.ch05;
02 
03 import fang2.core.Game;
04 import fang2.sprites.CompositeSprite;
05 import fang2.sprites.LineSprite;
06 import fang2.sprites.OvalSprite;
07 
08 // FANG Demonstration program: CompositeSprite
09 public class AxisSnowman
10   extends Game {
11   private CompositeSprite redSnowman;
12 
13   // spin the snowman about 4 times a minute; see how everything
14   // moves relative to (0.0, 0.0) ON snowman; 24 degrees/second
15   @Override
16   public void advance(double secondsSinceLastCall{
17     redSnowman.rotateDegrees(24.0 * secondsSinceLastCall);
18   }
19 
20   // add three circles to snowman, add snowman to scene
21   @Override
22   public void setup() {
23     redSnowman = new CompositeSprite();
24 
25     OvalSprite head = new OvalSprite(0.30.3);
26     head.setColor(getColor("SCG Red"));
27     head.setLocation(0, -0.35);
28     redSnowman.addSprite(head);
29 
30     OvalSprite middle = new OvalSprite(0.40.4);
31     middle.setColor(getColor("SCG Red"));
32     middle.setLocation(0.00.0);
33     redSnowman.addSprite(middle);
34 
35     OvalSprite bottom = new OvalSprite(0.50.5);
36     bottom.setColor(getColor("SCG Red"));
37     bottom.setLocation(00.45);
38     redSnowman.addSprite(bottom);
39 
40     LineSprite yAxis = new LineSprite(0, -0.500.5);
41     yAxis.setColor(getColor("white"));
42     redSnowman.addSprite(yAxis);
43 
44     LineSprite xAxis = new LineSprite(-0.500.50);
45     xAxis.setColor(getColor("white"));
46     redSnowman.addSprite(xAxis);
47 
48     // snowman scaled and placed off center on screen
49     redSnowman.setLocation(0.670.67);
50     redSnowman.setScale(0.50);
51     addSprite(redSnowman);
52   }
53 }
54 
55 //Uploaded on Mon Mar 29 21:40:30 EDT 2010


Download/View scg/ch05/AxisSnowman.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games