package com.wh.game;
/**
* 游戏类的父类
* @author 16572
*
*/
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
public class GameObject {
Image img;
double x, y;
int speed;
int width, height;
/**
* 画对应子类的图形
*
* @param g
*/
public void printObject(Graphics g) {
g.drawImage(img, (int) x, (int) y, null);
}
/**
* 获得对应的矩形
*/
public Rectangle getRectangle() {
return new Rectangle((int) x, (int) y, width, height);
}
/**
* 几种可能的构造方法
*/
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(Image img, double x, double y, int speed) {
super();
this.img = img;
this.x = x;
this.y = y;
this.speed = speed;
}
public GameObject() {
super();
}
}
GameObject类
最新推荐文章于 2022-11-17 20:21:32 发布