scg/ch05/Snowman

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.OvalSprite;
06 
07 // FANG Demonstration program: CompositeSprite
08 public class Snowman
09   extends Game {
10   private CompositeSprite redSnowman;
11 
12   // spin the snowman about 4 times a minute; see how everything
13   // moves relative to (0.0, 0.0) ON the snowman; 24 degrees/second
14   @Override
15   public void advance(double secondsSinceLastCall{
16     redSnowman.rotateDegrees(24.0 * secondsSinceLastCall);
17   }
18 
19   // add three circles to snowman, add snowman to scene
20   @Override
21   public void setup() {
22     redSnowman = new CompositeSprite();
23 
24     OvalSprite head = new OvalSprite(0.30.3);
25     head.setColor(getColor("SCG Red"));
26     head.setLocation(0, -0.25);
27     redSnowman.addSprite(head);
28 
29     OvalSprite middle = new OvalSprite(0.40.4);
30     middle.setColor(getColor("SCG Red"));
31     middle.setLocation(0.00.0);
32     redSnowman.addSprite(middle);
33 
34     OvalSprite bottom = new OvalSprite(0.50.5);
35     bottom.setColor(getColor("SCG Red"));
36     bottom.setLocation(00.35);
37     redSnowman.addSprite(bottom);
38 
39     // snowman scaled and placed off center on screen
40     redSnowman.setLocation(0.670.67);
41     redSnowman.setScale(0.50);
42     addSprite(redSnowman);
43   }
44 }
45 
46 //Uploaded on Mon Mar 29 21:39:25 EDT 2010


Download/View scg/ch05/Snowman.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