加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
GameObj 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
南岸之南 提交于 2022-06-16 18:54 . obj1
import main.GameWin;
import java.awt.*;
public class GameObj {
//物体基本属性的定义:图片、坐标、宽高、移速、窗口的引用
Image img;//定义Imag类型的静态数组
int x;
int y;
int width;
int height;
double speed;
GameWin frame;
public Image getImg() {
return img;
}
public void setImg(Image img) {
this.img = img;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public double getSpeed() {
return speed;
}
public void setSpeed(double speed) {
this.speed = speed;
}
public GameWin getFrame() {
return frame;
}
public void setFrame(GameWin frame) {
this.frame = frame;
}
public GameObj() {
}
public GameObj(int x, int y) {
this.x = x;
this.y = y;
}
public GameObj(Image img, int x, int y, double speed) {
this.img = img;
this.x = x;
this.y = y;
this.speed = speed;
}
public GameObj(Image img, int x, int y, int width, int height, double speed, GameWin frame) {
this.img = img;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.speed = speed;
this.frame = frame;
}
//绘制自身的方法
public void paintSelf(Graphics gImage){
gImage.drawImage(img,x,y,null);
}
//获取自身矩形,用于碰撞检测
public Rectangle getRec(){
return new Rectangle(x,y,width,height);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化