// SRVector Class // SRVector.java // Project 3, CIS 525 // Fall 2000 // By Terrence Burrows // Imports import java.awt.*; /** This class extends the SpriteVector class and overrides the methods "isPointInside" and "collision". This allows the program to distinguish which Sprite is being clicked (because of z-order it would by default indicate the "gun" Sprite) and eliminate Sprite collision detection. This class is taken directly from the book "Teach yourself Internet Game Programming with Java in 21 days" by Michael Morrison. See chapter 13 for details. */ public class SRVector extends SpriteVector { public SRVector(Background back) { super(back); } /** This method is necessary to determine when and "Eye" class has been clicked by the mouse otherwise because of the z-ordering of bitmap images the "gun" image would always be returned. */ Sprite isPointInside(Point pt) { // Iterate backward through the sprites, testing each for (int i = (size() - 1); i >= 0; i--) { Sprite s = (Sprite)elementAt(i); if ((s.getClass().getName().equals("Eyes")) && s.isPointInside(pt)) return s; } return null; } /** None of the Sprites need collision handling so this method is overridden to do nothing. */ protected boolean collision(int i, int iHit) { // Do nothing! return false; } }