⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmobstacle.java

📁 联机坦克游戏
💻 JAVA
字号:
/*
 * Created on 2005-1-27
 *
 * battle
 */
package components;

import java.awt.Graphics2D;
import java.awt.Image;

import shape.IShape;
import shape.Polygon;


/**
 * @author AnSen
 * 
 * Obstacles wall& others
 */
public class GmObstacle extends GmComponent implements IScriptRender{

	protected Image image=null;
	
	public GmObstacle(IShape shp) {
		super();
		this.ishpframe = shp;
	}

	public GmObstacle() {
		super();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see components.GmComponent#renderImage(java.awt.Graphics2D)
	 */
	public void renderImage(Graphics2D g2D, int left, int top,
			int width, int height) {
		if (ishpframe instanceof Polygon) {
			Polygon shp = (Polygon) this.ishpframe;
			g2D.drawPolygon(shp.getAwtPolygon(left,top));
		}
	}
	
	/* (non-Javadoc)
	 * @see components.IScriptRender#isRenderable(int, int, int, int)
	 */
	public boolean isRenderable(int left, int top, int width, int height) {
		if (ishpframe instanceof Polygon) {
			Polygon shp = (Polygon) this.ishpframe;
			for(int i=0;i<shp.npoints;i++){
				if(shp.xdps[i]>left&&shp.xdps[i]<left+width&&
						shp.ydps[i]>top&&shp.ydps[i]<top+height){
					return true;
				}
			}
		}
		return false;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -