I don’t understand what you mean.
Paddle constructor:
// class constructor
public Paddle(double x, double y, double width, double height)
{
// set the paddles x position
setX(x);
// set the paddles y position
setY(y);
// set the paddles width
setWidth(width);
// set the paddles height
setHeight(height);
// set the paddles shape
setShape(new Rectangle((int)getX(), (int)getY(), (int)getWidth(), (int)getHeight()));
}
Ball Constructor:
// class constructor
public Ball(double x, double y, double width, double height)
{
// set the balls x position
setX(x);
// set the balls y position
setY(y);
// set the balls width
setWidth(width);
// set the balls height
setHeight(height);
// set the balls shape
setShape(new Rectangle((int)getX(), (int)getY(), (int)getWidth(), (int)getHeight()));
}
I don’t see any g2d.transform() in there anywhere. If you mean changing my EightBitOoze constructor as follows:
public final void init()
{
// create the backbuffer for smooth graphics
backbuffer = new BufferedImage(getSize().width, getSize().height, BufferedImage.TYPE_INT_RGB);
g2d = backbuffer.createGraphics();
// create the identity transform
identity = new AffineTransform();
// create an instance of the paddle object
paddle = new Paddle(getSize().width / 4, 106, 32, 8);
// set the paddle's x velocity
paddle.setVX(2);
// create an instance of the ball object
ball = new Ball(getSize().width / 4, 10, 8, 8);
// set the players score to 0
score = 1234;
// start the user input listener
addKeyListener(this);
}
And changing the update method to:
public final void update(Graphics g)
{
// erase the background
g2d.setPaint(Color.LIGHT_GRAY);
g2d.fillRect(0, 0, getSize().width, getSize().height);
// draw the statusbar
g2d.setPaint(Color.GREEN);
g2d.fillRect(0, getSize().height - STATUSBARHEIGHT, getSize().width, STATUSBARHEIGHT);
// draw the players score
g2d.setPaint(Color.WHITE);
g2d.drawString("Score: " + Integer.toString(score), 0, (getSize().height - STATUSBARHEIGHT) + (STATUSBARHEIGHT /2));
// draw the ball
g2d.setPaint(Color.BLUE);
g2d.translate(ball.getX(), ball.getY());
g2d.fill(ball.getShape());
// draw the paddle
g2d.translate(paddle.getX(), paddle.getY());
g2d.fill(paddle.getShape());
// repaint the applet window
paint(g);
}
Then please let me know as I’m not sure what you mean when you say I’m translating on the ball/paddle constructor when I can’t see a single translate call in them. Any assistance in this matter would be greatly appreciated.
Sincerely,
8BitOoze