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類
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.