// (c) 1998 Ekkehard Kraemer (ekraemer@pluto.camelot.de) import java.awt.*; /** * Sorry, not documented yet. *

* Source */ class Block extends Item implements Runnable { Block(BojngInterface bojng,Image img,int action) { super(action); this.bojng=bojng; this.img=img; } void init(int blockX,int blockY,int bwidth,int bheight) { this.blockX=blockX; this.blockY=blockY; this.width=img.getWidth(null); this.height=img.getHeight(null); this.x=bwidth*blockX+(bwidth-width)/2; this.y=bheight*blockY+(bheight-height)/2; draw(); } void draw() { bojng.drawImage(img,x,y); Image ovl=null; switch (action) { case BULLETS: ovl=Images.bullet; break; } if (delay>0) { ovl=Images.delay[delay-1]; } if (ovl!=null) bojng.drawImage(ovl,x+img.getWidth(null)/2-ovl.getWidth(null)/2, y+img.getHeight(null)/2-ovl.getHeight(null)/2); // bojng._update().add(this); } void hit() { if (delay<1) { bojng.removeItem(blockX,blockY); if (hasAnim()) playAnimAndClear(); else bojng.clearBlock(blockX,blockY); } else { delay--; draw(); } } boolean hasAnim() { return true; } void playAnimAndClear() { (new Thread(this)).start(); } public void run() { try { for (int t=0; t<3; t++) { bojng.drawBackground(x,y,width,height); bojng.update(); Thread.sleep(50); draw(); bojng.update(); Thread.sleep(50); } } catch (Exception e) {} finally { bojng.drawBackground(x,y,width,height); } } BojngInterface bojng; Image img; }