?? bullet.java
字號:
/*
* Created on 2005-2-6
*
* tank components
*/
package components;
import java.awt.Graphics2D;
import java.awt.Image;
import java.util.Vector;
import java.util.Properties;
import resource.ResourceFactory;
import shape.*;
/**
* @author AnSen
*
* Bullet
*/
public class Bullet extends GmMovComponent implements IScriptRender{
private static String resourceID = "BULLET";
/**
* @param life
* @param ptX
* @param ptY
* @param width
* @param height
* @param direct
* @param container
*/
public Bullet(double ptX, double ptY, int width, int height, double direct,
Vector container) {
super(-1, ptX, ptY, width, height, direct, container);
initBullet();
}
private void initBullet() {
this.isMoving = true;
this.addGmListener(new GmMovCpAdapter() {
public void hitWallProformed(double x, double y) {
removeOject();
}
public void removeProformed() {
Explode bomb = new Explode(ptX, ptY, vContainer);
vContainer.addElement(bomb);
}
});
Properties prop = ResourceFactory.getInstance().getProperties(
resourceID);
Polygon frame = Polygon.parsePolygon(prop.getProperty("FRAME"));
frame.offset(ptX, ptY);
this.ishpframe = frame;
this.lLife = Long.parseLong(prop.getProperty("LIFE"));
this.width = Integer.parseInt(prop.getProperty("WIDTH"));
this.height = Integer.parseInt(prop.getProperty("HEIGHT"));
this.iSpeed = Integer.parseInt(prop.getProperty("SPEED"));
this.dSpeed = iSpeed;
this.iMaxFrames = Integer.parseInt(prop.getProperty("MAXFRAMES"));
this.images = (Image[]) prop.get("IMAGES");
}
public void upSpeed() {
}//cancel acc speed
/* (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;
}
/* (non-Javadoc)
* @see components.IScriptRender#renderImage(java.awt.Graphics2D, int, int, int, int)
*/
public void renderImage(Graphics2D g2D, int left, int top, int width,
int height) {
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);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -