scg/ch03/Diamond

From FANG

Jump to: navigation, search

01 package scg.ch03;
02 
03 import fang2.core.Game;
04 import fang2.sprites.RectangleSprite;
05 
06 /**
07  * A simple game demonstrating how to draw a red square on the screen
08  * and then rotate it to make it into a diamond.
09  */
10 
11 public class Diamond
12   extends Game {
13   /**
14    * Setup all of the sprites appearing in the game. A diamond is a
15    * square rotated 45 degrees. This draws a single diamond in the
16    * center of the screen.
17    */
18   @Override
19   public void setup() {
20     // make background white
21     setBackground(getColor("white"));
22 
23     // create the diamond, set its color, position, and rotation
24     RectangleSprite diamond = new RectangleSprite(0.10.1);
25     diamond.setColor(getColor("red"));
26     diamond.setLocation(0.50.5);
27     diamond.rotateDegrees(45.0);
28     addSprite(diamond);
29   }
30 }
31 
32 //Uploaded on Mon Mar 29 21:39:41 EDT 2010


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