package com.bjsxt;
import java.awt.*;
/*
* 游戏物体的根类
* */
public class GameObject {
Image image;//该物体对应的图片对象
double x,y; //该物体的坐标
int speed;//该物体的运行速度
int width,height;//该物体所在矩形区域的宽度和高度
public GameObject() {
}
/*
* 该怎么样绘制本对象
* */
public void drawMySelf(Graphics g){//构造无参方法
g.drawImage(image,(int)x,(int)y,null);
}
public GameObject(Image image, double x, double y, int speed) {
this.image = image;
this.x = x;
this.y = y;
if (image != null) {
this.width = image.getWidth(null);
this.height = image.getHeight(null);
}
}
public GameObject(Image image, double x, double y, int speed, int width, int height) {
this.image = image;
this.x = x;
this.y = y;
this.speed = speed;
this.width = width;
this.height = height;
}
public GameObject(Image image, double x, double y){
}
//返回物体对应矩形区域,便于后续在碰撞检测中使用
public Rectangle getRect(){
return new Rectangle((int) x,(int) y,width,height);
}
}
老师我是不是这个游戏物体的根类构造错了啊咋运行的时候没有飞机啊
