package starpunk.logic;

import com.artemis.Entity;
import com.artemis.World;
import com.badlogic.gdx.math.MathUtils;
import starpunk.logic.components.Position;
import starpunk.logic.components.Sprite;
import starpunk.logic.components.Velocity;

public final class EntityFactory
{
  private EntityFactory()
  {
  }

  /**
   * Create a star entity within a particular bound.
   */
  public static Entity createStar( final World world, final int width, final int height )
  {
    final Entity e = world.createEntity();

    final Position position = new Position();
    position.setX( MathUtils.random( -width / 2, width / 2 ) );
    position.setY( MathUtils.random( -height / 2, height / 2 ) );
    e.addComponent( position );

    final Velocity velocity = new Velocity();
    velocity.setVectorX( 0.05f * MathUtils.random( -width / 2, width / 2 ) );
    velocity.setVectorY( 0.05f * MathUtils.random( -height / 2, height / 2 ) );
    e.addComponent( velocity );

    final Sprite sprite = new Sprite();
    sprite.setName( "star" );
    final float scale = MathUtils.random( 0.5f, 1f );
    sprite.setScaleY( scale );
    sprite.setScaleX( scale );
    sprite.setRotation( MathUtils.random( 0f, 360f ) );
    sprite.setR( MathUtils.random( 0.3f, 0.9f ) );
    sprite.setG( MathUtils.random( 0.3f, 0.9f ) );
    sprite.setB( MathUtils.random( 0.3f, 0.9f ) );
    sprite.setA( MathUtils.random( 0.1f, 0.5f ) );
    sprite.setLayer( Sprite.Layer.BACKGROUND );

    e.addComponent( sprite );

    return e;
  }
}

@@ -1501,11 +1501,486 @@
 n e;%0A  %7D
+%0A%0A  public static Entity createShip( final World world, final int x, final int y )%0A  %7B%0A    final Entity e = world.createEntity();%0A%0A    final Position position = new Position();%0A    position.setX( x );%0A    position.setY( y );%0A    e.addComponent( position );%0A%0A    e.addComponent( new Velocity() );%0A%0A    final Sprite sprite = new Sprite();%0A    sprite.setName( %22images/u_fighter%22 );%0A    sprite.setLayer( Sprite.Layer.BACKGROUND );%0A%0A    e.addComponent( sprite );%0A    return e;%0A  %7D
 %0A%7D%0A

Add a factory for the ship