/** * SquareSprite.java * @author Jeff Ondich, 5 November 2010 * * The abstract parent class for Sprites in the Playground example. */ import java.awt.*; public class SquareSprite extends Sprite { private Color squareColor; private int squareWidth; public SquareSprite(int x, int y, int vx, int vy, Color color) { super(x, y, vx, vy); this.squareColor = color; this.squareWidth = 50; } /** * Required implementation of Sprite's abstract draw method. */ public void draw(Graphics g) { Color previousColor = g.getColor(); g.setColor(this.squareColor); g.fillRect(this.positionX, this.positionY, this.squareWidth, this.squareWidth); g.setColor(Color.BLACK); g.drawRect(this.positionX, this.positionY, this.squareWidth, this.squareWidth); g.setColor(previousColor); } }