|
TargetGame
LSBullet.java
//-----------------------------------------------------------------------------
// Class: LSBullet
// Author: Written by Chuck Cusack
// Date: September 2001
// Description: An extension of ABullet that draws bullets similar to those
// used in Light Storm toy guns.
//
//-----------------------------------------------------------------------------
import ABullet;
import java.awt.*;
import java.awt.event.*;
import aLibrary.*;
//-----------------------------------------------------------------------------
public class LSBullet extends ABullet {
//-----------------------------------------------------------------------------
// The instance variables
//
private ARectangle base; // The base of the bullet
private AOval tip; // The tip of the bullet
//-----------------------------------------------------------------------------
// the constructor.
// Simply callst the ABullet constructor, which draw according to the
// functiond defined below.
//
public LSBullet(int x,int y) {
super(x,y,16,6); // Since super calls drawBullet, no need to call it.
}
//-----------------------------------------------------------------------------
// draws the bullet as specified below.
// does NOT place it on anything.
//
protected void drawBullet() {
tip=new AOval(8,0,6,6);
tip.setColor(Color.yellow);
tip.setToFill();
tip.place(this);
base=new ARectangle(0,0,10,6);
base.setToFill();
base.setColor(Color.gray);
base.place(this);
this.repaint();
}
//-----------------------------------------------------------------------------
// Draw the bullet as described in the BulletTimer class
//
protected void drawBulletFiring(TargetGame D) {
BulletTimer theTimer=new BulletTimer(this,D);
theTimer.scheduleEvents(.01);
}
//-----------------------------------------------------------------------------
}
|