Posted by: Java_help April 22, 2011
Login in to Rate this Post:
0
?
package pingpong;
import java.awt.*;
/*
*
* paddle
*
*/
class paddle
{
final int PADDLE_HEIGHT = 60;
int x_pos, y_pos, new_y_pos;
Graphics g;
int getTop()
{
return y_pos;
}
int getBottom()
{
return y_pos + PADDLE_HEIGHT;
}
paddle(int x, int y)
{
x_pos = x;
y_pos = y;
new_y_pos = y;
}
void setGraphics (Graphics gr)
{
g = gr;
}
void draw ()
{
g.setColor(Color.white);
g.fillRect( x_pos, y_pos, 10, PADDLE_HEIGHT);
g.setColor(Color.black);
y_pos = new_y_pos;
g.fillRect( x_pos, y_pos, 10, PADDLE_HEIGHT);
}
void move (int y)
{
new_y_pos = y;
}
}