content: /*
   * FXGL - JavaFX Game Library. The MIT License (MIT).
   * Copyright (c) AlmasB (almaslvl@gmail.com).
   * See LICENSE for details.
   */
  
  package sandbox.saving;
  
  import com.almasb.fxgl.entity.component.Component;
  import com.almasb.fxgl.entity.components.TransformComponent;
  
  /**
   * @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)
   */
  public class PlayerControl extends Component {
  
      private TransformComponent position;
  
      private double speed = 0;
  
      @Override
      public void onAdded() {
          position = entity.getComponent(TransformComponent.class);
      }
  
      @Override
      public void onUpdate(double tpf) {
          speed = tpf * 60;
      }
  
      public void up() {
          position.translateY(-5 * speed);
      }
  
      public void down() {
          position.translateY(5 * speed);
      }
  
      public void left() {
          position.translateX(-5 * speed);
      }
  
      public void right() {
          position.translateX(5 * speed);
      }
  
      @Override
      public boolean isComponentInjectionRequired() {
          return false;
      }
  }
  