simulation_InteractiveVersion.sprites
Class ImageSprite
java.lang.Object
simulation_InteractiveVersion.sprites.ImageSprite
- All Implemented Interfaces:
- Sprite
public class ImageSprite
- extends java.lang.Object
- implements Sprite
This class encapsulates a sprite which is an image of a dog that is 100x100
units wide and tall. circle of diameter 10 units and color red. The sprite's
initial position is randomly chosen. For each frame, this sprite moves a
random number of units up or down and a random number of unit to the left or
right, wrapping around the canvas when the boundaries are encountered. The
sprite will be drawn partially when it encounters the bottom and right
boundaries, but not the top and left boundaries. The maximum displacement at
each frame is 5 units in each of the horizontal and vertical dimensions.
- Author:
- mb
Field Summary |
static java.util.logging.Logger |
logger
|
Constructor Summary |
ImageSprite(int widthOfDrawingRegion,
int heightOfDrawingRegion)
Creates a sprite within a game world with the specified dimensions. |
Method Summary |
void |
draw(java.awt.Graphics2D g)
Takes the passed Graphics2D object and specifies how this sprite should
be drawn on it. |
void |
move()
Specify what should happen at each frame. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
public static java.util.logging.Logger logger
ImageSprite
public ImageSprite(int widthOfDrawingRegion,
int heightOfDrawingRegion)
- Creates a sprite within a game world with the specified dimensions.
- Parameters:
widthOfDrawingRegion
- as described aboveheightOfDrawingRegion
- as described above
draw
public void draw(java.awt.Graphics2D g)
- Description copied from interface:
Sprite
- Takes the passed Graphics2D object and specifies how this sprite should
be drawn on it.
- Specified by:
draw
in interface Sprite
move
public void move()
- Description copied from interface:
Sprite
- Specify what should happen at each frame.
- Specified by:
move
in interface Sprite