intro/MultiPlayerGame

From ggc

Jump to: navigation, search

01 package intro;
02 
03 import fang.*;
04 import java.awt.*;
05 import java.awt.geom.*;
06 
07 /**
08  * All about my game.
09  @author My Name Here
10  */
11 public class MultiPlayerGame extends Game
12 {
13   /**an oval*/
14   private Sprite[] oval;
15 
16   /**sets up the game*/
17   public void setup()
18   {
19     makeSprites();
20     addSprites();
21   }
22 
23   /**makes the sprites*/
24   private void makeSprites()
25   {
26     oval=new Sprite[getNumberOfPlayers()];
27     for(int i=0; i<oval.length; i++)
28     {
29       oval[i]=new OvalSprite(21);
30       oval[i].setSize(0.75);
31       oval[i].setLocation(0.50.5);
32 
33     }
34   }
35 
36   /**adds the sprites to the screen*/
37   private void addSprites()
38   {
39     addSprite(oval);
40   }
41 
42   /**handle input and game events*/
43   public void advance()
44   {
45     for(int i=0; i<oval.length; i++)
46     {
47       oval[i].setLocation(getMouse2D(i));
48       if(getClick2D(i)!=null)
49       {
50         oval[i].setSize(randomDouble());
51       }
52       if(getKeyPressed(i)=='q')
53       {
54         oval[i].setColor(Palette.getColor("red"));
55       }
56       if(getKeyPressed(i)=='w')
57       {
58         oval[i].setColor(Palette.getColor("white"));
59       }
60     }
61   }
62 }


Download/View intro/MultiPlayerGame.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