Package dwlab.shapes.sprites

Examples of dwlab.shapes.sprites.Sprite


 
  @Override
  public void init() {
    ball.visualizer = new Visualizer( "3F3F7F", 1d, true );
    cursor = new Sprite( 0d, 0d, 1d );
    cursor.visualizer = new Visualizer( "7FFF3F", 1d, true );
  }
View Full Code Here


      tileMap.setTile( 0, n ,bricksTile );
      tileMap.setTile( mapSize - 1, n, bricksTile );
    }
    tileMap.tileSet.collisionSprites = new Sprite[ 3 ][];
    for( int n = 1; n < 3; n ++ ) tileMap.tileSet.collisionSprites[ n ] = new Sprite[ 1 ];
    tileMap.tileSet.collisionSprites[ 1 ][ 0 ] = new Sprite( 0.5d, 0.5d, 1d, 1d );
    tileMap.tileSet.collisionSprites[ 2 ][ 0 ] = new Sprite( 0.5d, 0.5d, 1d );
  }
View Full Code Here

 
  @Override
  public void init() {
    rectangle.visualizer = new ContourVisualizer( 0.1, "FF0000" );
    for( int n = 0; n <= 6; n++ ) {
      ball[ n ] = new Sprite( 0d, 0d, 0.5d * ( 7 - n ) );
      ball[ n ].visualizer.setRandomColor();
    }
  }
View Full Code Here


  @Override
  public void init() {
    for( int n = 1; n <= spritesQuantity; n++ ) {
      oldSprite = new Sprite( ShapeType.oval, Service.random( -15, 15 ), Service.random( -11, 11 ), 0d, 0d, Service.random( 360 ), 5 );
      oldSprite.setDiameter( Service.random( 0.5, 1.5 ) );
      oldSprite.visualizer.setRandomColor();
      layer.addLast( oldSprite );
    }
  }
View Full Code Here

  @Override
  public void logic() {
    ang = 1500 * Math.sin( 7 * time );
    for( Shape shape : layer.children ) {
      Sprite sprite = shape.toSprite();
      oldSprite.directTo( sprite );
      oldSprite.angle += perSecond( ang ) + Service.random( -45, 45 );
      sprite.moveForward();
      oldSprite = sprite;
    }

    if( save.wasPressed() ) layer.saveToFile( "sprites.lw" );
    if( load.wasPressed() ) layer = (Layer) Obj.loadFromFile( "sprites.lw" );
View Full Code Here

  ButtonAction select = ButtonAction.create( MouseButton.create( MouseButton.LEFT_BUTTON ) );

 
  @Override
  public void init() {
    cursor = new Sprite(){
      SpriteCollisionHandler handler = new SpriteCollisionHandler() {
        @Override
        public void handleCollision( Sprite sprite1, Sprite sprite2 ) {
          selected = sprite2;
        }
      };

      @Override
      public void act() {
        setMouseCoords();
        if( select.wasPressed() ) {
          selected = null;
          collisionsWith( Layer, handler );
        }
      }
    };
   
    for( int n = 1; n <= spritesQuantity; n++ ) {
      Sprite sprite = new Sprite( ShapeType.oval, Service.random( -15, 15 ), Service.random( -11, 11 ), 0d, 0d, 1d, Service.random( 360 ) );
      sprite.setDiameter( Service.random( 1, 3 ) );
      sprite.visualizer.setRandomColor();
      sprite.visualizer.image = spriteImage;
      Layer.addLast( sprite );
    }
View Full Code Here

 
  @Override
  public void init() {
    Visualizer spriteVisualizer = new Visualizer( "res/mario.png", 4, 1 );
    for( int n = 1; n <= spritesQuantity; n++ ) {
      Sprite sprite = new Sprite( Service.random( -15d, 15d ), Service.random( -11d, 11d ), Service.random( 0.5d, 2d ), Service.random( 0.5d, 2d ) );
      sprite.visualizer = spriteVisualizer;
      Layer.addLast( sprite );
    }
  }
View Full Code Here

  /**
   * Draws path (given as list of pivots) using given visualizer.
   */
  public static void drawPath( LinkedList<Sprite> path, Visualizer visualizer, Color drawingColor ) {
    if( path == null ) return;
    Sprite oldPivot = null;
    for( Sprite pivot: path ) {
      if( oldPivot != null ) ( new LineSegment( pivot, oldPivot ) ).drawUsingVisualizer( visualizer, drawingColor );
      oldPivot = pivot;
    }
  }
View Full Code Here



  public void spread( LinkedList<Sprite> path, Sprite fromPivot, Sprite toPivot, double length ) {
    for( LineSegment line: contents.get( fromPivot ) ) {
      Sprite otherPivot = ( line.pivot[ 0 ] == fromPivot ? line.pivot[ 1 ] : line.pivot[ 0 ] ) ;
      double newLength = length + fromPivot.distanceTo( otherPivot );
      if( newLength + otherPivot.distanceTo( toPivot ) > maxLength ) continue;
      while( true ) {
        if( lengthMap.containsKey( otherPivot ) ) {
          if( lengthMap.get( otherPivot ) < newLength ) break;
        }
        LinkedList<Sprite> newPath = new LinkedList<Sprite>();
View Full Code Here


  @Override
  public void drawUsingTileMap( TileMap tileMap, LinkedList shapes, Color drawingColor ) {
    if( !tileMap.visible ) return;
    Sprite sprite = new Sprite();
    sprite.jumpTo( tileMap );
    sprite.setSize( tileMap.getWidth(), tileMap.getHeight() );
    drawUsingSprite( sprite );
  }
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.