GBell/MakeBricks

From ggc

Jump to: navigation, search

01 package GBell;
02 
03 import wiki.Wiki;
04 import fang.*;
05 import java.awt.*;
06 import java.awt.geom.*;
07 
08 /**
09  * All about my game here.
10  @author Gbell
11  */
12 public class MakeBricks extends GameLoop
13 {
14   private Sprite[] bricks;
15 
16   public void startGame()
17   {
18     bricks=new Sprite[40];
19     makeSprites();
20   }
21 
22   private void makeSprites()
23   {
24     int index=0;
25     int numBricksHigh=4;
26     double startLocationY=0.1;
27     double endLocationY=.25;
28     double distanceHigh=endLocationY-startLocationY;
29     for(int j=0; j<numBricksHigh; j++)
30     {
31       double y=j*distanceHigh/(numBricksHigh-1)+startLocationY;
32 
33       int numBricksAcross=10;
34       double startLocationX=0.1;
35       double endLocationX=1-startLocationX;
36       double distanceAcross=endLocationX-startLocationX;
37       for(int i=0; i<numBricksAcross; i++)
38       {
39         double x=i*distanceAcross/(numBricksAcross-1)+startLocationX;
40         bricks[index]=new RectangleSprite(2.41.25);
41         bricks[index].setScale(.085);
42         bricks[index].setLocation(x, y);
43         bricks[index].setColor(Color.RED);
44         canvas.addSprite(bricks[index]);
45         index++;
46       }
47     }
48   }
49 }


Download/View GBell/MakeBricks.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