alba07 0 Newbie Poster

I am supposed to do a sliding target class, then make a shooter class that shoots up three balls when the user clicks. I think I have the first two classes done, but I am stuck on the class that has three balls to shoot at the target.

These have to be tested separately, then all together.

Any help is appriciated.

import objectdraw. *;
import java.awt. *;


public class SlidingTarget extends ActiveObject {


// size of target
private static final int SIZE = 20;


//the delay between sucessive moves of the target
private static final int DELAY_TIME = 33;


//number of pixels target moves in a single move
private static final double X_STEP = 4;


//the image of target
private FilledOval target;


//the canvas
private DrawingCanvas canvas;


public SlidingTarget (Location initalLocation, DrawingCanvas aCanvas) {


canvas = aCanvas;
target = new FilledOval(initalLocation, SIZE, SIZE, canvas);
start();


}
public void run() {
while (target.getX() < canvas.getWidth()) {
target.move(X_STEP,0);
pause(DELAY_TIME);
}



while (target.getX() > 0 )  {
target.move(-X_STEP,0);
pause (DELAY_TIME);


}


}


Next class shooter: Is this correct? I feel I am missing something.


import objectdraw.*;
import java.awt.*;


public class Shooter extends WindowController {


private static final int SIZE = 20;
private FilledRect shooter;


public void begin () {


shooter = new FilledRect (canvas.getWidth(), 600)
}
public void onMouseClick ( Location point) {
// make a new shooter when clicked
new Shooter (point, canvas)
}


public static void main (String [] args)  {
new Shooter().startController (600, 600);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.