OtherShapes

From ggc

Jump to: navigation, search

01 import fang.*;
02 import java.awt.*;
03 
04 /**
05  * All about my game here.
06  @author Jam Jenkins
07  */
08 public class OtherShapes extends GameLoop
09 {
10    /**an oval*/
11    private Sprite oval;
12    
13    /**sets up the game*/
14    public void startGame()
15    {
16       makeSprites();
17       addSprites();
18    }
19    
20    /**makes the sprites*/
21    private void makeSprites()
22    {
23       oval=new PolygonSprite(5);
24       oval.setScale(0.75);
25       oval.setLocation(0.50.5);
26    }
27    
28    /**adds the sprites to the screen*/
29    private void addSprites()
30    {
31       canvas.addSprite(oval);
32    }
33    
34    /**handle input and game events*/
35    public void advanceFrame(double timePassed)
36    {
37       oval.setLocation(getPlayer().getMouse().getLocation());
38       if(getPlayer().getMouse().getClickLocation()!=null)
39       {
40          oval.setScale(random.nextDouble());
41       }
42       if(getPlayer().getKeyboard().getLastKey()=='r')
43       {
44          oval.setColor(Color.RED);
45       }
46       if(getPlayer().getKeyboard().getLastKey()=='w')
47       {
48          oval.setColor(Color.WHITE);
49       }
50    }
51 }


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