simulation_MVC_Basic
Class ShapeSprite
java.lang.Object
simulation_MVC_Basic.ShapeSprite
public class ShapeSprite
- extends java.lang.Object
This class encapsulates a sprite which is an image (as determined by the File
that is passed to the constructor). The sprite's initial position is randomly
chosen. 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. The sprite has a random movement behaviour defined for it (moving
to the left/right and up/down a randomly-chosen number of units). The sprite
knows how to draw itself, given a Graphics2D instance.
- Author:
- mb
Field Summary |
static java.util.logging.Logger |
logger
|
Constructor Summary |
ShapeSprite(int widthOfDrawingRegion,
int heightOfDrawingRegion,
java.io.File file)
Creates a sprite within a game world with the specified dimensions. |
Method Summary |
void |
draw(java.awt.Graphics2D g)
|
void |
move()
|
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
ShapeSprite
public ShapeSprite(int widthOfDrawingRegion,
int heightOfDrawingRegion,
java.io.File file)
- 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)
move
public void move()