Package dwlab.shapes.sprites

Examples of dwlab.shapes.sprites.Sprite



  public static SpriteTemplate fromSprites( LinkedList<Sprite> sprites, Layer layer, Shape pivotShape, Relativity relativity ) {
    SpriteTemplate template = null;
    double leftX = 0d, topY = 0d, rightX = 0d, bottomY = 0d;
    Sprite newSprite = new Sprite();

    for( Sprite sprite : sprites ) {
      if( sprite.shapeType.getNum() == ShapeType.spriteTemplate.getNum() ) continue;
      if( template != null ) {
        leftX = Math.min( leftX, sprite.leftX() );
        topY = Math.min( topY, sprite.topY() );
        rightX = Math.max( rightX, sprite.rightX() );
        bottomY = Math.max( bottomY, sprite.bottomY() );
      } else {
        template = new SpriteTemplate();
        leftX = sprite.leftX();
        topY = sprite.topY();
        rightX = sprite.rightX();
        bottomY = sprite.bottomY();
        if( pivotShape == null ) pivotShape = sprite;
      }
    }

    if( template != null ) {
      newSprite.setCoords( 0.5d * ( leftX + rightX ), 0.5d * ( topY + bottomY ) );
      newSprite.setHeight( bottomY - topY );
      newSprite.shapeType = template;
      if( layer != null ) layer.insert( newSprite, pivotShape, relativity );

      for( Sprite sprite : sprites ) {
        if( sprite.shapeType.getNum() == ShapeType.spriteTemplate.getNum() ) continue;
        layer.remove( sprite );
        sprite.setCoords( ( newSprite.getX() - sprite.getX() ) / newSprite.getWidth(), ( newSprite.getY() - sprite.getY() ) / newSprite.getHeight() );
        sprite.setSize( sprite.getWidth() / newSprite.getWidth(), sprite.getHeight() / newSprite.getHeight() );
        template.sprites.addLast( sprite );
      }
    }

    return template;
View Full Code Here


  public void toSprites( Sprite sprite, Layer layer, Shape pivotShape, Relativity relativity ) {
    LinkedList newSprites = new LinkedList();
    if( pivotShape == null ) pivotShape = sprite;
    for( Sprite templateSprite : sprites ) {
      Sprite newSprite = new Sprite();
      templateSprite.copySpriteTo( newSprite );
      setShape( sprite, templateSprite, newSprite );
      newSprites.addLast( newSprite );
    }
    layer.insert( newSprites, pivotShape, relativity );
View Full Code Here

  ButtonAction changeShape = ButtonAction.create( MouseButton.create( MouseButton.RIGHT_BUTTON ) );

 
  @Override
  public void init() {
    cursor = new Sprite( 0, 0, 16, 16 );
    pivot.visualizer.set( "FF0000" );
    oval.visualizer.set( "00FF00" );
    rectangle.visualizer.set( "0000FF" );
    triangle.visualizer.set( "007FFF" );
    cursor.visualizer.alpha = 0.5;
View Full Code Here

  Sprite rectangle = new Sprite( 0, 0, 30, 20 );

 
  @Override
  public void init() {
    cursor = new Sprite( 0, 0, 8, 6 );
    for( int n = 1; n < spritesQuantity; n++ ) {
      Sprite sprite = new Sprite( ShapeType.oval, Service.random( -13d, 13d ), Service.random( -8d, 8d ), 0d, 0d, Service.random( Math.PI * 2d ),
          Service.random( 3d, 7d ) );
      sprite.setDiameter( Service.random( 0.5d, 1.5d ) );
      sprite.visualizer.setRandomColor();
      layer.addLast( sprite );
    }
  }
View Full Code Here

 
  @Override
  public void logic() {
    for( Shape shape : layer.children ) {
      Sprite sprite = shape.toSprite();
      sprite.moveForward();
      sprite.bounceInside( rectangle );
    }
  }
View Full Code Here

      area.setCoords( ball1.getX() + ( ball2.getX() - ball1.getX() ) * ball1.getDiameter() / diameters, ball1.getY() + ( ball2.getY() - ball1.getY() ) * ball1.getDiameter() / diameters );
      area.setSize( 4d, 4d );
      area.startingTime = instance.time;
      double angle = ball1.directionTo( ball2 ) + 0.5d * Math.PI;
      for( int n = 1; n <= particlesQuantity; n++ ) {
        Sprite particle = new Sprite();
        particle.jumpTo( area );
        particle.angle = angle + Service.random( -Math.PI / 12d, Math.PI / 12d ) + ( n % 2 ) * Math.PI;
        particle.setDiameter( Service.random( 0.2d, 0.6d ) );
        particle.velocity = Service.random( 0.5d, 3d );
        area.particles.addLast( particle );
      }
      area.insertTo( fieldSpriteMap );
    }
View Full Code Here

  ButtonAction paint = ButtonAction.create( MouseButton.create( MouseButton.LEFT_BUTTON ) );
  ButtonAction changeBrush = ButtonAction.create( MouseButton.create( MouseButton.RIGHT_BUTTON ) );
 
  @Override
  public void init() {
    cursor = new Sprite( 0, 0, 2, 2 );
    tileMap.setSize( tileMapWidth * 2, tileMapHeight * 2 );
    for( int y = 0; y < tileMapHeight; y++ ) {
      for( int x = 0; x < tileMapWidth; x++ ) {
        tileMap.setTile( x, y, (int) Service.random( 1, 31 ) );
      }
View Full Code Here

 
 
  @Override
  public void init() {
    for( int n = 1; n <= spritesQuantity; n++ ) {
      Sprite sprite = new Sprite( ShapeType.oval, Service.random( -15, 15 ), Service.random( -11, 11 ), 1, 1 );
      sprite.setDiameter( Service.random( 1, 3 ) );
      sprite.displayingAngle= Service.random( 360 );
      sprite.visualizer.setRandomColor();
      sprite.visualizer.image = spriteImage;
      sprite.visualizer.setVisualizerScales( 1.3 );
      sprites.addLast( sprite );
View Full Code Here

 
  @Override
  public void logic() {
    if( clone.wasPressed() ) {
      Sprite sprite = cursor.lastCollidedSpriteOf( sprites );
      if( sprite != null ) {
        Sprite newSprite = sprite.clone();
        newSprite.alterCoords( Service.random( -2, 2 ), Service.random( -2, 2 ) );
        newSprite.alterDiameter( Service.random( 0.75, 1.5 ) );
        newSprite.alterAngle( Service.random( -45, 45 ) ) ;
        sprites.addLast( newSprite );
      }
    }
  }
View Full Code Here

    }
   

    @Override
    public void init( Shape shape ) {
      area = new Sprite();
      area.shapeType = ShapeType.oval;
      area.setDiameter( 0.3 );
      period = AwPossum.hitPeriod;
      awPossumHitCollision.collided = false;
    }
View Full Code Here

TOP

Related Classes of dwlab.shapes.sprites.Sprite

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.