這是飛機大戰遊戲的基礎工具類代碼及解釋,其他的也在博客中
遊戲接口有三個,統一放在com.airbattle.gameinterface包下
接口 | 用途 |
GameObjectInterface |
遊戲元素接口,每個遊戲元素都必須實現。後來被拋棄了,因爲我代碼水平不夠 最後從瀑布模型轉化成了迅捷開發 |
FlyingObjectInterface | 飛行器需要實現的接口,主要包含開火和被擊中時的處理接口 |
HeroplaneInterface | 英雄機接口,
後來被拋棄了,因爲我代碼水平不夠 最後從瀑布模型轉化成了迅捷開發 |
接口最後沒什麼意義,可以不看
GameObjectInterface接口
package com.airbattle.gameinterface;
public interface GameObjectInterface {
public abstract void moveStep();
}
FlyingObjectInterface接口
package com.airbattle.gameinterface;
import com.airbattle.gameobject.Bullet;
public interface FlyingObjectInterface {
public abstract Bullet fire();
public abstract void onHit(int numHit);
}
HeroplaneInterface接口
package com.airbattle.gameinterface;
public interface HeroplaneInterface {
public abstract void transform();
public abstract int getHealth();
public abstract int getScore();
}