scg/ch03/Circle

From FANG

Jump to: navigation, search

01 package scg.ch03;
02 
03 import fang2.core.Game;
04 import fang2.sprites.OvalSprite;
05 import fang2.transformers.VelocityTransformer;
06 import fang2.transformers.WrapTransformer;
07 
08 // FANG Demonstration program: OvalSprite,
09 public class Circle
10   extends Game {
11   // Called before game loop: create named oval and add
12   @Override
13   public void setup() {
14     OvalSprite oval = new OvalSprite(0.20.2);
15     oval.setColor(getColor("cornflower blue"));
16     oval.setLocation(0.50.5);
17     addSprite(oval);
18 
19     OvalSprite o2 = new OvalSprite(0.050.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 =
24       new VelocityTransformer(25.01.0);
25     oval.addTransformer(velocityTransformer);
26     o2.addTransformer(velocityTransformer);
27     // wrapping means wrapping from left to right or top to bottom
28     WrapTransformer wrapTransformer = new WrapTransformer();
29     oval.addTransformer(wrapTransformer);
30     o2.addTransformer(wrapTransformer);
31   }
32 }
33 
34 //Uploaded on Mon Mar 29 21:42:12 EDT 2010


Download/View scg/ch03/Circle.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