<commit_before>package info.meoblast001.seallyracing;

import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.scene.Spatial;
import info.meoblast001.seallyracing.states.PlayState;

/**
 * Collect player input and respond to it.
 */
public class PlayerInput implements AnalogListener, ActionListener {
  // Movement directions.
  public static final String MOVE_LEFT = "Left";
  public static final String MOVE_RIGHT = "Right";
  public static final String MOVE_UP = "Up";
  public static final String MOVE_DOWN = "Down";

  // Player character.
  private Spatial player;

  public PlayerInput(Spatial player) {
    this.player = player;
  }

  /**
   * Handle input which triggers a single aaction.
   * @see ActionListener#onAction(String, boolean, float)
   */
  public void onAction(String name, boolean keyPressed, float tpf) {
    // Currently no actions.
  }

  /**
   * Handle input which may have intensity and occurs over multiple frames.
   * @see AnalogListener#onAnalog(String, float, float)
   */
  public void onAnalog(String name, float value, float tpf) {
    if (name.equals(MOVE_LEFT)) {
      player.rotate(0.0f, PlayState.PLAYER_TORQUE * tpf, 0.0f);
    } else if (name.equals(MOVE_RIGHT)) {
      player.rotate(0.0f, -PlayState.PLAYER_TORQUE * tpf, 0.0f);
    } else if (name.equals(MOVE_UP)) {
      player.rotate(-PlayState.PLAYER_TORQUE * tpf, 0.0f, 0.0f);
    } else if (name.equals(MOVE_DOWN)) {
      player.rotate(PlayState.PLAYER_TORQUE * tpf, 0.0f, 0.0f);
    }
  }
}
<commit_msg>Player rotation around Y axis is around world axis<commit_after>package info.meoblast001.seallyracing;

import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import info.meoblast001.seallyracing.states.PlayState;

/**
 * Collect player input and respond to it.
 */
public class PlayerInput implements AnalogListener, ActionListener {
  // Movement directions.
  public static final String MOVE_LEFT = "Left";
  public static final String MOVE_RIGHT = "Right";
  public static final String MOVE_UP = "Up";
  public static final String MOVE_DOWN = "Down";

  // Player character.
  private Spatial player;

  public PlayerInput(Spatial player) {
    this.player = player;
  }

  /**
   * Handle input which triggers a single aaction.
   * @see ActionListener#onAction(String, boolean, float)
   */
  public void onAction(String name, boolean keyPressed, float tpf) {
    // Currently no actions.
  }

  /**
   * Handle input which may have intensity and occurs over multiple frames.
   * @see AnalogListener#onAnalog(String, float, float)
   */
  public void onAnalog(String name, float value, float tpf) {
    if (name.equals(MOVE_LEFT)) {
      Quaternion rotation = new Quaternion();
      rotation.fromAngleAxis(PlayState.PLAYER_TORQUE * tpf, Vector3f.UNIT_Y);
      rotation.multLocal(player.getLocalRotation());
      player.setLocalRotation(rotation);
    } else if (name.equals(MOVE_RIGHT)) {
      Quaternion rotation = new Quaternion();
      rotation.fromAngleAxis(-PlayState.PLAYER_TORQUE * tpf, Vector3f.UNIT_Y);
      rotation.multLocal(player.getLocalRotation());
      player.setLocalRotation(rotation);
    } else if (name.equals(MOVE_UP)) {
      player.rotate(-PlayState.PLAYER_TORQUE * tpf, 0.0f, 0.0f);
    } else if (name.equals(MOVE_DOWN)) {
      player.rotate(PlayState.PLAYER_TORQUE * tpf, 0.0f, 0.0f);
    }
  }
}

{'fraction_non_alphanumeric': 0.11020062164453236, 'fraction_numerical': 0.013280587736648771, 'mean_word_length': 3.7644683714670255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1691713', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1137, 'n_words': 284}