scg/ch02/BasketBall

From FANG

Jump to: navigation, search

01 package scg.ch02;
02 
03 import fang2.core.Game;
04 import fang2.sprites.RectangleSprite;
05 
06 /**
07  * Throw a basketball sprite. BasketBallLauncher knows about
08  * BasketBallSprite so we just add the launcher. When the mouse is
09  * clicked, the launcher launches a basket ball along the given line
10  * (gravity and bouncing change its course).
11  */
12 public class BasketBall
13   extends Game {
14   /**
15    * Setup the sprites (and anything else) necessary for our game.
16    */
17   @Override
18   public void setup() {
19     // width, height (in screens); location is (x, y), in screens
20     RectangleSprite rectangleBottom = new RectangleSprite(0.250.05);
21     rectangleBottom.setLocation(0.6250.475);
22     addSprite(rectangleBottom);
23 
24     RectangleSprite rectangleBackboard = new RectangleSprite(0.050.4);
25     rectangleBackboard.setLocation(0.750.3);
26     addSprite(rectangleBackboard);
27 
28     RectangleSprite rectangleFrontboard = new RectangleSprite(0.05,
29         0.2);
30     rectangleFrontboard.setLocation(0.500.4);
31     addSprite(rectangleFrontboard);
32 
33     // location of the anchor point (launch point, too)
34     BasketBallLauncherSprite launcher = new BasketBallLauncherSprite(0.050.5);
35     addSprite(launcher);
36   }
37 }
38 
39 //Uploaded on Mon Mar 29 21:42:37 EDT 2010


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