paddle.java
来自「不但实现了所有的游戏功能」· Java 代码 · 共 41 行
JAVA
41 行
import java.awt.Color;
import acm.graphics.GRect;
public class Paddle extends GRect{
/** Dimensions of the paddle */
private static final int PADDLE_WIDTH = 60;
private static final int PADDLE_HEIGHT = 10;
/** Offset of the paddle up from the bottom */
private static final int PADDLE_Y_OFFSET = 30;
public Paddle(int Width, int Height) {
super((Width - PADDLE_WIDTH) / 2, Height - PADDLE_Y_OFFSET, PADDLE_WIDTH, PADDLE_HEIGHT);
this.setFilled(true);
this.setFillColor(Color.BLUE);
y_offset = Height - PADDLE_Y_OFFSET;
x_extreme_right = Width - PADDLE_WIDTH;
}
public int getOriginalY(){
return y_offset;
}
public int getExtremeRightX(){
return x_extreme_right;
}
private int y_offset; //original Y_Offset
private int x_extreme_right;//the extreme right x cordinate
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?