com.threerings.puzzle.drop.client
Class DropBlockSprite

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.sprite.Sprite
          extended by com.threerings.puzzle.drop.client.DropSprite
              extended by com.threerings.puzzle.drop.client.DropBlockSprite
All Implemented Interfaces:
com.threerings.media.util.Pathable, DirectionCodes, Shape

public class DropBlockSprite
extends DropSprite

The drop block sprite represents a block of multiple pieces that can be rotated to any of the four cardinal compass directions. As such, it may span multiple columns or rows depending on its orientation. The block has a "central" piece around which it rotates, with the other pieces referred to as "external" pieces.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.puzzle.drop.client.DropSprite
DropSprite.PieceMovedOp
 
Nested classes/interfaces inherited from class com.threerings.media.sprite.Sprite
com.threerings.media.sprite.Sprite.CancelledOp, com.threerings.media.sprite.Sprite.CompletedOp
 
Field Summary
protected  int[] _cols
          The drop block piece columns.
protected  Rectangle _dbounds
          The drop block bounds in board coordinates.
protected  int _ecol
          The external piece location in board coordinates.
protected  int _erow
          The external piece location in board coordinates.
protected  byte _popups
          How many times this sprite can be popped-up a row in a forgiving rotation.
protected  int[] _rows
          The drop block piece rows.
 
Fields inherited from class com.threerings.puzzle.drop.client.DropSprite
_bouncing, _col, _destPos, _dist, _endstamp, _offx, _offy, _pieces, _renderPos, _row, _rowstamp, _srcPos, _stopstamp, _unit, _vel, _view, DEFAULT_VELOCITY, ORIENT_DX, ORIENT_DY
 
Fields inherited from class com.threerings.media.sprite.Sprite
_orient, _ox, _oxoff, _oy, _oyoff, _path, _pathStamp
 
Fields inherited from class com.threerings.media.AbstractMedia
_bounds, _firstTick, _mgr, _observers, _renderOrder, HUD_LAYER
 
Fields inherited from interface com.threerings.util.DirectionCodes
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST
 
Constructor Summary
DropBlockSprite(DropBoardView view, int col, int row, int orient, int[] pieces)
          Constructs a drop block sprite and starts it dropping.
DropBlockSprite(DropBoardView view, int col, int row, int orient, int[] pieces, int renderOrder)
          Constructs a drop block sprite and starts it dropping.
 
Method Summary
protected  int calculateExternalColumn()
          Returns the column the external piece is located in based on the current central piece location and sprite orientation.
protected  int calculateExternalRow()
          Returns the row the external piece is located in based on the current central piece location and sprite orientation.
 boolean canPopup()
          Can this sprite pop-up a row on a forgiving rotation?
 void didPopup()
          Called if we pop up to decrement the remaining popups we have.
 Rectangle getBoardBounds()
          Returns the bounds of the block in board piece coordinates.
 int[] getColumns()
          Returns an array of the column numbers containing the block pieces.
 int getExternalColumn()
          Returns the column the external piece is located in.
 int getExternalRow()
          Returns the row the external piece is located in.
 int[] getRows()
          Returns an array of the row numbers containing the block pieces.
protected  void init()
           
 void setBoardLocation(int row, int col)
          Sets the row and column the piece is located in.
 void setColumn(int col)
          Sets the column the piece is located in.
 void setOrientation(int orient)
          Updates the sprite image offset to reflect the direction in which the external piece is hanging.
 void setRow(int row)
          Set the row the piece is located in.
 void toString(StringBuilder buf)
           
protected  void updateDropInfo()
          Re-calculates the external piece position and bounds of the drop block.
 
Methods inherited from class com.threerings.puzzle.drop.client.DropSprite
advancePosition, drop, fastForward, getColumn, getDistance, getPercentDone, getPieces, getRow, getVelocity, inside, isBouncing, isDropping, paint, paintPieceImage, setBouncing, setColumnOffset, setPieces, setRowOffset, setVelocity, shiftForBounce, stop, tick, updateBounds, updatePosition, updateRenderOffset
 
Methods inherited from class com.threerings.media.sprite.Sprite
addSpriteObserver, cancelMove, contains, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, hitTest, intersects, isMoving, move, paintPath, pathBeginning, pathCompleted, removeSpriteObserver, setLocation, shutdown, tickPath, updateRenderOrigin, viewLocationDidChange
 
Methods inherited from class com.threerings.media.AbstractMedia
addObserver, contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, intersects, intersects, invalidate, invalidateAfterChange, naturalCompareTo, queueNotification, removeObserver, renderCompareTo, setRenderOrder, toString, willStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.threerings.media.util.Pathable
getBounds
 

Field Detail

_popups

protected byte _popups
How many times this sprite can be popped-up a row in a forgiving rotation.


_dbounds

protected Rectangle _dbounds
The drop block bounds in board coordinates.


_rows

protected int[] _rows
The drop block piece rows.


_cols

protected int[] _cols
The drop block piece columns.


_ecol

protected int _ecol
The external piece location in board coordinates.


_erow

protected int _erow
The external piece location in board coordinates.

Constructor Detail

DropBlockSprite

public DropBlockSprite(DropBoardView view,
                       int col,
                       int row,
                       int orient,
                       int[] pieces)
Constructs a drop block sprite and starts it dropping.

Parameters:
view - the board view upon which this sprite will be displayed.
col - the column of the central piece.
row - the row of the central piece.
orient - the orientation of the sprite.
pieces - the pieces displayed by the sprite.

DropBlockSprite

public DropBlockSprite(DropBoardView view,
                       int col,
                       int row,
                       int orient,
                       int[] pieces,
                       int renderOrder)
Constructs a drop block sprite and starts it dropping.

Parameters:
view - the board view upon which this sprite will be displayed.
col - the column of the central piece.
row - the row of the central piece.
orient - the orientation of the sprite.
pieces - the pieces displayed by the sprite.
renderOrder - the rendering order of the sprite.
Method Detail

init

protected void init()
Overrides:
init in class DropSprite

getRows

public int[] getRows()
Returns an array of the row numbers containing the block pieces. The first index is the row of the central piece. The array is cached and re-used internally and so the caller should make their own copy if they care to modify it.


getColumns

public int[] getColumns()
Returns an array of the column numbers containing the block pieces. The first index is the column of the central piece. The array is cached and re-used internally and so the caller should make their own copy if they care to modify it.


getBoardBounds

public Rectangle getBoardBounds()
Returns the bounds of the block in board piece coordinates. The bounds rectangle is cached and re-used internally and so the caller should make their own copy if they care to modify it.


getExternalRow

public int getExternalRow()
Returns the row the external piece is located in.


getExternalColumn

public int getExternalColumn()
Returns the column the external piece is located in.


setColumn

public void setColumn(int col)
Description copied from class: DropSprite
Sets the column the piece is located in.

Overrides:
setColumn in class DropSprite

setRow

public void setRow(int row)
Description copied from class: DropSprite
Set the row the piece is located in.

Overrides:
setRow in class DropSprite

setBoardLocation

public void setBoardLocation(int row,
                             int col)
Description copied from class: DropSprite
Sets the row and column the piece is located in.

Overrides:
setBoardLocation in class DropSprite

setOrientation

public void setOrientation(int orient)
Updates the sprite image offset to reflect the direction in which the external piece is hanging.

Specified by:
setOrientation in interface com.threerings.media.util.Pathable
Overrides:
setOrientation in class DropSprite

toString

public void toString(StringBuilder buf)
Overrides:
toString in class DropSprite

canPopup

public boolean canPopup()
Can this sprite pop-up a row on a forgiving rotation?


didPopup

public void didPopup()
Called if we pop up to decrement the remaining popups we have.


updateDropInfo

protected void updateDropInfo()
Re-calculates the external piece position and bounds of the drop block.


calculateExternalRow

protected int calculateExternalRow()
Returns the row the external piece is located in based on the current central piece location and sprite orientation.


calculateExternalColumn

protected int calculateExternalColumn()
Returns the column the external piece is located in based on the current central piece location and sprite orientation.