ChrisHull/wackadot/Wackadot

From ggc

Jump to: navigation, search

001 
002 
003 package ChrisHull.wackadot;
004 
005 import wiki.Wiki;
006 import fang.*;
007 /**This is a fun, simple game I made using
008  * the FANG Engine.
009 *This game is based upon the Original Wackadot
010 *This program gave me many headaches hope you enjoy.
011  @author Chris Hull
012  */
013 import java.awt.*;
014 import java.awt.geom.*;
015 
016 public class Wackadot extends GameLoop
017 {
018   private void repositionRandomly(Sprite sprite)
019   {
020     sprite.setLocation(
021         random.nextDouble(),
022         random.nextDouble());
023   }
024 
025   private void handleCollisions()
026   {
027     if(dot.intersects(blueDot))
028     {
029       repositionRandomly(blueDot);
030       if(dot.getColor().equals(Color.BLUE))
031       {
032         dot.setColor(Color.RED);
033         score++;
034         goodsound.play();
035       }
036       else
037       {
038         score--;
039         badsound.play();
040       }
041       updateScore();
042     }
043     if(dot.intersects(redDot))
044     {
045       repositionRandomly(redDot);
046       if(dot.getColor().equals(Color.RED))
047       {
048         dot.setColor(Color.BLUE);
049         score++;
050         goodsound.play();
051       }
052       {
053         score--;
054         badsound.play();
055       }
056       updateScore();
057 
058     }
059   }
060 
061 
062   public void advanceFrame(double timePassed)
063   {
064     if(timeLeft>0)
065     {
066       Point2D.Double mouse=
067           getPlayer().getMouse().getLocation();
068       dot.setLocation(mouse);
069       handleCollisions();
070     }
071   }
072   private Sprite dot;
073   private Sprite redDot;
074   private Sprite blueDot;
075   private Sound goodsound;
076   private Sound badsound;
077   private StringSprite scoreSprite;
078   private int score;
079   private int timeLeft;
080   private StringSprite timerSprite;
081 
082 
083   public void startGame()
084 
085   {
086     toggleAudible();
087     score=0;
088     timeLeft=10;
089     makeSprites();
090     addSprites();
091     scheduleRelative(new TimeUpdater()1);
092     setHelp("resources/WackadotHelp.html");
093   }
094   class TimeUpdater implements Alarm
095   {
096     public void alarm()
097     {
098       timeLeft--;
099       updateTimer();
100       if(timeLeft>0)
101       {
102         scheduleRelative(this1);
103       }
104     }
105   }
106   private void makeSprites()
107   {
108     goodsound = new Sound(Wiki.getMedia("Clap.wav"));
109     badsound = new Sound(Wiki.getMedia("Boom.wav"));
110 
111     dot=new OvalSprite(11);
112     dot.setScale(0.1);
113     dot.setLocation(0.50.5);
114     dot.setColor(Color.RED);
115 
116     {
117       redDot=new ImageSprite(Wiki.getMedia("Red.JPG"));
118       redDot.setScale(0.1);
119       redDot.setLocation(
120           random.nextDouble(),
121           random.nextDouble());
122       redDot.setColor(Color.RED);
123 
124       blueDot=new ImageSprite(Wiki.getMedia("Blue.JPG"));
125       blueDot.setScale(0.1);
126       blueDot.setLocation(
127           random.nextDouble(),
128           random.nextDouble());
129 
130       blueDot.setColor(Color.BLUE);
131       scoreSprite=new StringSprite("Score: 0");
132       scoreSprite=new StringSprite("Score: "+score);
133       scoreSprite.setHeight(0.1);
134       scoreSprite.rightJustify();
135       scoreSprite.topJustify();
136       scoreSprite.setLocation(10);
137       timerSprite=new StringSprite("Timer: "+timeLeft);
138       timerSprite.leftJustify();
139       timerSprite.topJustify();
140       timerSprite.setHeight(0.1);
141       timerSprite.setLocation(00);
142     }
143   }
144   private void updateScore()
145   {
146     scoreSprite.setText("Score: "+score);
147   }
148 
149   private void addSprites()
150   {
151     canvas.addSprite(dot);
152     canvas.addSprite(redDot);
153     canvas.addSprite(blueDot);
154     canvas.addSprite(scoreSprite);
155     canvas.addSprite(timerSprite);
156   }
157   private void updateTimer()
158   {
159     timerSprite.setText("Timer: "+timeLeft);
160   }
161   ;
162 }

Compiler Errors:
----------
1. ERROR in ChrisHull/wackadot/Wackadot.java (at line 117)
	redDot=new ImageSprite(Wiki.getMedia("Red.JPG"));
	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2. ERROR in ChrisHull/wackadot/Wackadot.java (at line 124)
	blueDot=new ImageSprite(Wiki.getMedia("Blue.JPG"));
	        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2 problems (2 errors)

Download/View ChrisHull/wackadot/Wackadot.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