public void logic() {
if( dropPiece.wasPressed() ) {
IntVector tile = new IntVector();
tileMap.getTileForPoint( cursor.getX(), cursor.getY(), tile );
if( tileMap.getTile( tile.x, tile.y ) > 0 ) {
VectorSprite piece = new VectorSprite(){
double gravity = 8.0;
public double startingTime = time;
public double angularDirection = -1 + 2 * ( (int) Service.random( 0, 1 ) );
@Override
public void act() {
moveForward();
angle = Math.PI * 0.25 * ( time - startingTime ) * angularDirection;
dY += perSecond( gravity );
if( topY() > tileMap.bottomY() ) removeFrom( pieces );
}
};
pieces.addFirst( piece );
piece.setAsTile( tileMap, tile.x, tile.y );
tileMap.setTile( tile.x, tile.y, 0 );
}
}
pieces.act();
}