ImageExampleSummer

From ggc

Jump to: navigation, search

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


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