scg/ch04/NewtonsAppleDropApple

From FANG

Jump to: navigation, search

01 package scg.ch04;
02 
03 import fang2.core.Game;
04 import fang2.sprites.OvalSprite;
05 import fang2.sprites.RectangleSprite;
06 
07 /** NewtonsApple pre-prototype */
08 public class NewtonsAppleDropApple
09   extends Game {
10   // An OvalSprite field to name the apple
11   private OvalSprite apple;
12   // A RectangleSprite field to name newton
13   private RectangleSprite newton;
14 
15   /**
16    * place the apple at random x-coord at top of screen.
17    */
18   public void dropApple() {
19     apple.setLocation(randomDouble()0.00);
20   }
21   
22   // First pass at defining the sprites for the game
23   @Override
24   public void setup() {
25     apple = new OvalSprite(0.100.10);
26     apple.setColor(getColor("red"));
27     dropApple();
28 
29     newton = new RectangleSprite(0.100.10);
30     newton.setColor(getColor("green"));
31     newton.setLocation(0.500.90);
32 
33     addSprite(newton);
34     addSprite(apple);
35   }
36 }
37 
38 //Uploaded on Mon Mar 29 21:38:42 EDT 2010


Download/View scg/ch04/NewtonsAppleDropApple.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