scg/ch02/ScreenCoords

From FANG

Jump to: navigation, search

01 package scg.ch02;
02 
03 import fang2.core.Game;
04 import fang2.sprites.RectangleSprite;
05 import fang2.sprites.StringSprite;
06 
07 /**
08  * Draws two rectangles as axes across the center of the screen (shows
09  * off some odd color names) and then labels the origin, center, and
10  * extent points on the screen.
11  */
12 public class ScreenCoords
13   extends Game {
14   /**
15    Set up the sprites to display on the screen. Five sprites are
16    * created and added to the game.
17    */
18   @Override
19   public void setup() {
20     RectangleSprite vertical = new RectangleSprite(0.051.0);
21     vertical.setColor(getColor("pink"128));
22     vertical.setLocation(0.50.5);
23     addSprite(vertical);
24 
25     RectangleSprite horizontal = new RectangleSprite(1.00.05);
26     horizontal.setColor(getColor("cornflower blue"128));
27     horizontal.setLocation(0.50.5);
28     addSprite(horizontal);
29 
30     // labels: string (in quotes), height (in screens)
31     StringSprite origin = new StringSprite("(0.0, 0.0)");
32     origin.setLineHeight(0.05);
33     origin.setColor(getColor("white"));
34     origin.setLocation(0.10.05);
35     addSprite(origin);
36 
37     StringSprite extent = new StringSprite("(1.0, 1.0)");
38     extent.setLineHeight(0.05);
39     extent.setColor(getColor("white"));
40     extent.setLocation(0.90.95);
41     addSprite(extent);
42 
43     StringSprite center = new StringSprite("(0.5, 0.5)");
44     center.setLineHeight(0.05);
45     center.setColor(getColor("white"));
46     center.setLocation(0.630.55);
47     addSprite(center);
48   }
49 }
50 
51 //Uploaded on Mon Mar 29 21:39:52 EDT 2010


Download/View scg/ch02/ScreenCoords.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