scg/ch04/NewtonsAppleAdvance

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 NewtonsAppleAdvance
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    * Update the game state: only game state here is where the apple is;
17    * let it fall each frame. Velocity is 0.10 screen/second.
18    */
19   @Override
20   public void advance(double secondsSinceLastCall{
21     apple.translateY(0.10 * secondsSinceLastCall);
22   }
23   
24   // First pass at defining the sprites for the game
25   @Override
26   public void setup() {
27     apple = new OvalSprite(0.100.10);
28     apple.setColor(getColor("red"));
29     apple.setLocation(0.500.00);
30 
31     newton = new RectangleSprite(0.100.10);
32     newton.setColor(getColor("green"));
33     newton.setLocation(0.500.90);
34 
35     addSprite(newton);
36     addSprite(apple);
37   }
38 }
39 
40 //Uploaded on Mon Mar 29 21:41:53 EDT 2010


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