PavitraDPullay/wackadot/Wackadot

From ggc

Jump to: navigation, search

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

Compiler Errors:
----------
1. ERROR in PavitraDPullay/wackadot/Wackadot.java (at line 103)
	dot=new ImageSprite(Wiki.getMedia("Pavitra.jpg"));
	    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
2. ERROR in PavitraDPullay/wackadot/Wackadot.java (at line 108)
	redDot=new ImageSprite(Wiki.getMedia("Annie.jpg"));
	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ImageSprite(URL) is undefined
----------
3 problems (3 errors)

Download/View PavitraDPullay/wackadot/Wackadot.java

/** Had help from Hemendra and Blake

    • //




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