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

📄 explode.java

📁 联机坦克游戏
💻 JAVA
字号:
/*
 * Created on 2005-2-6
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package components;

import java.awt.Graphics2D;
import java.awt.Image;
import java.util.Properties;
import java.util.Vector;

import resource.ResourceFactory;
import shape.IShape;


/**
 * @author AnSen
 * 
 *Explode class effect no frame
 */
public class Explode extends GmAutomatic implements IScriptRender{
	
	private static String resourceID = "EXPLODE";
	
	private int iRadius=1;
	private int iDamage=0;
	/**
	 * @param ptX
	 * @param ptY
	 * @param container
	 */
	public Explode(double ptX, double ptY, Vector container) {
		super(-1, ptX, ptY, container);
		Properties prop = ResourceFactory.getInstance().getProperties(
				resourceID);
		this.lLife = Long.parseLong(prop.getProperty("LIFE"));
		this.iMaxFrames =Integer.parseInt(prop.getProperty("MAXFRAMES"));
		this.iRadius=Integer.parseInt(prop.getProperty("RADIUS"));
		this.iDamage=Integer.parseInt(prop.getProperty("DAMAGE"));
		
		this.images=(Image[])prop.get("IMAGES");
		
		this.isPlaying=true;
		for(int i=0;i<this.vContainer.size();i++){
			GmComponent obj=(GmComponent)vContainer.get(i);
			IShape frame=obj.getFrame();
			if(frame!=null){
				if(frame.isSuperpose(ptX,ptY,iRadius)){
					obj.damnify(iDamage);
				}
			}
		}
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see components.GmComponent#renderImage(java.awt.Graphics2D, int, int,
	 *      int, int)
	 */
	public void renderImage(Graphics2D g2D, int left, int top, int width,
			int height) {
		/*
		 * if (this.images == null) { return; }
		 */	
		int ptX, ptY;
		ptX = this.getPositionX() - left - images[iCurrFrame].getWidth(null)/2;
		ptY = this.getPositionY() - top - images[iCurrFrame].getHeight(null)/2;
		g2D.drawImage(images[iCurrFrame], ptX, ptY, null);
	}
	
	/* (non-Javadoc)
	 * @see components.IScriptRender#isRenderable(int, int, int, int)
	 */
	public boolean isRenderable(int left, int top, int width, int height) {
		if (ptX > left && ptX < left + width &&
				ptY > top && ptY < top + height) {
			return true;
		}
		return false;
	}
}

⌨️ 快捷键说明

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