scg/ch03/Bee

From FANG

Jump to: navigation, search

01 package scg.ch03;
02 
03 import fang2.core.Game;
04 import fang2.sprites.OvalSprite;
05 
06 /**
07  * Draws a simple bumble bee (sans stripes) in the center of the screen.
08  * Demonstrates how to use transformations (to rotate the oval wings),
09  * sprite outlines, and transparent colors.
10  */
11 public class Bee
12   extends Game {
13   /**
14    * Setup the "game": create four sprites: body, head, left wing and
15    * right wing. Place the body in the center of the screen and position
16    * the other sprites accordingly (slightly above, to the left and to
17    * the right of the bee's body.
18    */
19   @Override
20   public void setup() {
21     // Let the bee fly on a grassy background.
22     setBackground(getColor("green"));
23 
24     OvalSprite beeBody = new OvalSprite(0.50.7);
25     beeBody.setColor(getColor("Goldenrod"));
26     beeBody.setLocation(0.50.6);
27     beeBody.setOutlineColor(getColor("black"));
28     beeBody.setOutlineThickness(0.01);
29     beeBody.showOutline();
30     addSprite(beeBody);
31 
32     OvalSprite beeHead = new OvalSprite(0.350.35);
33     beeHead.setColor(getColor("black"));
34     beeHead.setLocation(0.50.18);
35     addSprite(beeHead);
36 
37     OvalSprite leftWing = new OvalSprite(0.350.7);
38     leftWing.setColor(getColor("Wheat"128));
39     leftWing.setOutlineColor(getColor("black"));
40     leftWing.setOutlineThickness(0.01);
41     leftWing.showOutline();
42     leftWing.rotateDegrees(+20.0);
43     leftWing.setLocation(0.360.6);
44     addSprite(leftWing);
45 
46     OvalSprite rightWing = new OvalSprite(0.350.7);
47     rightWing.setColor(getColor("Wheat"128));
48     rightWing.setOutlineColor(getColor("black"));
49     rightWing.setOutlineThickness(0.01);
50     rightWing.showOutline();
51     rightWing.rotateDegrees(-20.0);
52     rightWing.setLocation(0.640.6);
53     addSprite(rightWing);
54   }
55 }
56 
57 //Uploaded on Mon Mar 29 21:40:42 EDT 2010


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