tipgame.sprite
Class BlurSprite

java.lang.Object
  extended by tipgame.Sprite
      extended by tipgame.sprite.BlurSprite

public class BlurSprite
extends Sprite

This class provides a mechanism for showing the path of fast moving Sprites in which it is useful to draw the position of Sprites in intermediate frames between screen refresh. The Sprites are drawn with increasing opacity with time. The opacity works only for single color Sprites. In order to make an existing Sprite display motion blur, simply extend this class instead of the Sprite class.

Author:
Jam Jenkins

Field Summary
private static int DEFAULT_FRAMES
          the default number of previous frames to store
private static int DEFAULT_PER_FRAME
          the default number of Shapes to store per frame
private  int drawNumber
          used to indicate how many Shapes have been drawn
private  int numFrames
          the number of Shapes to store per frame
private  int numPerFrame
          the number of previous frames to store
private  java.util.LinkedList<java.awt.Shape> previous
          the previous Sprites as Shapes
 
Fields inherited from class tipgame.Sprite
color, tracker
 
Constructor Summary
BlurSprite()
           
 
Method Summary
 void paint(java.awt.Graphics2D brush)
          paints the current Sprite after painting the Sprite's previous locations in increasing opacity
 void setEnabled(boolean enabled)
          enables the sprite blur
 void setHistory(int frames, int perFrame)
          updates the number of previous frames to store and how many Shapes to store per frame
 void update(double time)
          adds to the list of previous Shapes
 
Methods inherited from class tipgame.Sprite
flipAlongHorizontalAxis, flipAlongVerticalAxis, getBounds2D, getColor, getLocation, getNormalVector, getRotation, getScale, getShape, getTracker, getUseBoundingBox, intersects, isDestroyed, isEnabled, isVisible, kill, normalize, paintInternal, rotate, scale, setColor, setLocation, setLocation, setRotation, setScale, setShape, setTracker, setUseBoundingBox, setVisible, translate, updateInternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

previous

private java.util.LinkedList<java.awt.Shape> previous
the previous Sprites as Shapes


DEFAULT_PER_FRAME

private static int DEFAULT_PER_FRAME
the default number of Shapes to store per frame


DEFAULT_FRAMES

private static int DEFAULT_FRAMES
the default number of previous frames to store


numFrames

private int numFrames
the number of Shapes to store per frame


numPerFrame

private int numPerFrame
the number of previous frames to store


drawNumber

private int drawNumber
used to indicate how many Shapes have been drawn

Constructor Detail

BlurSprite

public BlurSprite()
Method Detail

setEnabled

public void setEnabled(boolean enabled)
enables the sprite blur

Overrides:
setEnabled in class Sprite
Parameters:
enabled - true indicates the Sprite can display and update, false otherwise
See Also:
Sprite.setEnabled(boolean)

setHistory

public void setHistory(int frames,
                       int perFrame)
updates the number of previous frames to store and how many Shapes to store per frame

Parameters:
frames - the number of previous frames to store
perFrame - the number of Shapes per frame

update

public void update(double time)
adds to the list of previous Shapes

Overrides:
update in class Sprite
See Also:
tipgame.Sprite#update()

paint

public void paint(java.awt.Graphics2D brush)
paints the current Sprite after painting the Sprite's previous locations in increasing opacity

Overrides:
paint in class Sprite
Parameters:
brush - the Graphics used to draw the shape
See Also:
Sprite.paint(java.awt.Graphics2D)