package cn.sxt.game;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
/**
* 游戏物体的父类
* @author
*
*/
public class GameObject {
Image img;
double x,y;
int speed;
int width, height;
public void drawSelf(Graphics g){
g.drawImage(img, (int)x,(int) y, null);
}
public GameObject(Image img, double x, double y, int speed, int width, int height) {
super();
this.img = img;
this.x = x;
this.y = y;
this.speed = speed;
this.width = width;
this.height = height;
}
public GameObject(Image img, double x, double y) {
super();
this.img = img;
this.x = x;
this.y = y;
}
public GameObject() {
}
/**
* 返回物体所在的矩形。便于后续的碰撞检测。根据有没有相交实现
* Rectangle矩形
* @return
*/
public Rectangle getRect(){
return new Rectangle((int)x, (int)y, width, height);
}
}
最近下载更多
最近浏览更多
3334004690 LV11
2024年6月22日
ClydeSon LV5
2023年12月27日
微信网友_6790966844739584 LV5
2023年12月27日
2871581741 LV1
2023年12月22日
bangyiyang LV2
2023年12月21日
412836806
2023年10月13日
暂无贡献等级
yangxb2 LV10
2023年7月11日
2017143155 LV12
2023年6月26日
啊伟大伟大
2023年6月18日
暂无贡献等级
微信网友_6508798513811456 LV5
2023年6月7日

