Package dwlab.shapes.sprites

Examples of dwlab.shapes.sprites.VectorSprite


  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();
  }
View Full Code Here


    double newDistance = parentPivot.distanceTo( shape );
    if( newDistance == 0 ) {
      shape.setCoords( parentPivot.getX() + distance, parentPivot.getY() );
    } else {
      double k = distance / newDistance;
      VectorSprite vectorSprite = (VectorSprite) shape;
      if( vectorSprite != null ) {
        double dDistance = newDistance - distance;
        vectorSprite.dX += ( parentPivot.getX() - shape.getX() ) * dDistance;
        vectorSprite.dY += ( parentPivot.getY() - shape.getY() ) * dDistance;
        if( fixedAngle ) vectorSprite.updateAngularModel();
      }
      shape.setCoords( parentPivot.getX() + ( shape.getX() - parentPivot.getX() ) * k, parentPivot.getY() + ( shape.getY() - parentPivot.getY() ) * k );
    }
  }
View Full Code Here

TOP

Related Classes of dwlab.shapes.sprites.VectorSprite

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.